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