Show More
@@ -1,54 +1,54 | |||
|
1 | 1 | """Base TestCase class for testing Exporters""" |
|
2 | 2 | |
|
3 | 3 | #----------------------------------------------------------------------------- |
|
4 | 4 | # Copyright (c) 2013, the IPython Development Team. |
|
5 | 5 | # |
|
6 | 6 | # Distributed under the terms of the Modified BSD License. |
|
7 | 7 | # |
|
8 | 8 | # The full license is in the file COPYING.txt, distributed with this software. |
|
9 | 9 | #----------------------------------------------------------------------------- |
|
10 | 10 | |
|
11 | 11 | #----------------------------------------------------------------------------- |
|
12 | 12 | # Imports |
|
13 | 13 | #----------------------------------------------------------------------------- |
|
14 | 14 | |
|
15 | 15 | import os |
|
16 | 16 | |
|
17 |
from IPython.testing.decorators import onlyif_cmd |
|
|
17 | from IPython.testing.decorators import onlyif_any_cmd_exists | |
|
18 | 18 | |
|
19 | 19 | from ...tests.base import TestsBase |
|
20 | 20 | |
|
21 | 21 | #----------------------------------------------------------------------------- |
|
22 | 22 | # Class |
|
23 | 23 | #----------------------------------------------------------------------------- |
|
24 | 24 | |
|
25 | 25 | all_raw_mimetypes = { |
|
26 | 26 | 'text/x-python', |
|
27 | 27 | 'text/markdown', |
|
28 | 28 | 'text/html', |
|
29 | 29 | 'text/restructuredtext', |
|
30 | 30 | 'text/latex', |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | 33 | class ExportersTestsBase(TestsBase): |
|
34 | 34 | """Contains base test functions for exporters""" |
|
35 | 35 | |
|
36 | 36 | exporter_class = None |
|
37 | 37 | should_include_raw = None |
|
38 | 38 | |
|
39 | 39 | def _get_notebook(self, nb_name='notebook2.ipynb'): |
|
40 | 40 | return os.path.join(self._get_files_path(), nb_name) |
|
41 | 41 | |
|
42 |
@onlyif_cmd |
|
|
42 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
43 | 43 | def test_raw_cell_inclusion(self): |
|
44 | 44 | """test raw cell inclusion based on raw_mimetype metadata""" |
|
45 | 45 | if self.should_include_raw is None: |
|
46 | 46 | return |
|
47 | 47 | exporter = self.exporter_class() |
|
48 | 48 | (output, resources) = exporter.from_filename(self._get_notebook('rawtest.ipynb')) |
|
49 | 49 | for inc in self.should_include_raw: |
|
50 | 50 | self.assertIn('raw %s' % inc, output, "should include %s" % inc) |
|
51 | 51 | self.assertIn('no raw_mimetype metadata', output) |
|
52 | 52 | for exc in all_raw_mimetypes.difference(self.should_include_raw): |
|
53 | 53 | self.assertNotIn('raw %s' % exc, output, "should exclude %s" % exc) |
|
54 | 54 | self.assertNotIn('never be included', output) |
@@ -1,61 +1,61 | |||
|
1 | 1 | """Tests for HTMLExporter""" |
|
2 | 2 | |
|
3 | 3 | #----------------------------------------------------------------------------- |
|
4 | 4 | # Copyright (c) 2013, the IPython Development Team. |
|
5 | 5 | # |
|
6 | 6 | # Distributed under the terms of the Modified BSD License. |
|
7 | 7 | # |
|
8 | 8 | # The full license is in the file COPYING.txt, distributed with this software. |
|
9 | 9 | #----------------------------------------------------------------------------- |
|
10 | 10 | |
|
11 | 11 | #----------------------------------------------------------------------------- |
|
12 | 12 | # Imports |
|
13 | 13 | #----------------------------------------------------------------------------- |
|
14 | 14 | |
|
15 | 15 | from .base import ExportersTestsBase |
|
16 | 16 | from ..html import HTMLExporter |
|
17 |
from IPython.testing.decorators import onlyif_cmd |
|
|
17 | from IPython.testing.decorators import onlyif_any_cmd_exists | |
|
18 | 18 | |
|
19 | 19 | #----------------------------------------------------------------------------- |
|
20 | 20 | # Class |
|
21 | 21 | #----------------------------------------------------------------------------- |
|
22 | 22 | |
|
23 | 23 | class TestHTMLExporter(ExportersTestsBase): |
|
24 | 24 | """Tests for HTMLExporter""" |
|
25 | 25 | |
|
26 | 26 | exporter_class = HTMLExporter |
|
27 | 27 | should_include_raw = ['html'] |
|
28 | 28 | |
|
29 | 29 | def test_constructor(self): |
|
30 | 30 | """ |
|
31 | 31 | Can a HTMLExporter be constructed? |
|
32 | 32 | """ |
|
33 | 33 | HTMLExporter() |
|
34 | 34 | |
|
35 | 35 | |
|
36 |
@onlyif_cmd |
|
|
36 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
37 | 37 | def test_export(self): |
|
38 | 38 | """ |
|
39 | 39 | Can a HTMLExporter export something? |
|
40 | 40 | """ |
|
41 | 41 | (output, resources) = HTMLExporter().from_filename(self._get_notebook()) |
|
42 | 42 | assert len(output) > 0 |
|
43 | 43 | |
|
44 | 44 | |
|
45 |
@onlyif_cmd |
|
|
45 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
46 | 46 | def test_export_basic(self): |
|
47 | 47 | """ |
|
48 | 48 | Can a HTMLExporter export using the 'basic' template? |
|
49 | 49 | """ |
|
50 | 50 | (output, resources) = HTMLExporter(template_file='basic').from_filename(self._get_notebook()) |
|
51 | 51 | assert len(output) > 0 |
|
52 | 52 | |
|
53 | 53 | |
|
54 |
@onlyif_cmd |
|
|
54 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
55 | 55 | def test_export_full(self): |
|
56 | 56 | """ |
|
57 | 57 | Can a HTMLExporter export using the 'full' template? |
|
58 | 58 | """ |
|
59 | 59 | (output, resources) = HTMLExporter(template_file='full').from_filename(self._get_notebook()) |
|
60 | 60 | assert len(output) > 0 |
|
61 | 61 |
@@ -1,51 +1,51 | |||
|
1 | 1 | """Tests for SlidesExporter""" |
|
2 | 2 | |
|
3 | 3 | #----------------------------------------------------------------------------- |
|
4 | 4 | # Copyright (c) 2013, the IPython Development Team. |
|
5 | 5 | # |
|
6 | 6 | # Distributed under the terms of the Modified BSD License. |
|
7 | 7 | # |
|
8 | 8 | # The full license is in the file COPYING.txt, distributed with this software. |
|
9 | 9 | #----------------------------------------------------------------------------- |
|
10 | 10 | |
|
11 | 11 | #----------------------------------------------------------------------------- |
|
12 | 12 | # Imports |
|
13 | 13 | #----------------------------------------------------------------------------- |
|
14 | 14 | |
|
15 | 15 | from .base import ExportersTestsBase |
|
16 | 16 | from ..slides import SlidesExporter |
|
17 |
from IPython.testing.decorators import onlyif_cmd |
|
|
17 | from IPython.testing.decorators import onlyif_any_cmd_exists | |
|
18 | 18 | |
|
19 | 19 | #----------------------------------------------------------------------------- |
|
20 | 20 | # Class |
|
21 | 21 | #----------------------------------------------------------------------------- |
|
22 | 22 | |
|
23 | 23 | class TestSlidesExporter(ExportersTestsBase): |
|
24 | 24 | """Tests for SlidesExporter""" |
|
25 | 25 | |
|
26 | 26 | exporter_class = SlidesExporter |
|
27 | 27 | should_include_raw = ['html'] |
|
28 | 28 | |
|
29 | 29 | def test_constructor(self): |
|
30 | 30 | """ |
|
31 | 31 | Can a SlidesExporter be constructed? |
|
32 | 32 | """ |
|
33 | 33 | SlidesExporter() |
|
34 | 34 | |
|
35 | 35 | |
|
36 |
@onlyif_cmd |
|
|
36 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
37 | 37 | def test_export(self): |
|
38 | 38 | """ |
|
39 | 39 | Can a SlidesExporter export something? |
|
40 | 40 | """ |
|
41 | 41 | (output, resources) = SlidesExporter().from_filename(self._get_notebook()) |
|
42 | 42 | assert len(output) > 0 |
|
43 | 43 | |
|
44 | 44 | |
|
45 |
@onlyif_cmd |
|
|
45 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
46 | 46 | def test_export_reveal(self): |
|
47 | 47 | """ |
|
48 | 48 | Can a SlidesExporter export using the 'reveal' template? |
|
49 | 49 | """ |
|
50 | 50 | (output, resources) = SlidesExporter(template_file='slides_reveal').from_filename(self._get_notebook()) |
|
51 | 51 | assert len(output) > 0 |
General Comments 0
You need to be logged in to leave comments.
Login now