Show More
@@ -14,6 +14,9 b' from IPython.nbformat.current import (new_notebook, write, new_worksheet,' | |||
|
14 | 14 | new_heading_cell, new_code_cell, |
|
15 | 15 | new_output) |
|
16 | 16 | |
|
17 | from IPython.testing.decorators import onlyif_cmds_exist | |
|
18 | ||
|
19 | ||
|
17 | 20 | class NbconvertAPI(object): |
|
18 | 21 | """Wrapper for nbconvert API calls.""" |
|
19 | 22 | def __init__(self, base_url): |
@@ -71,6 +74,7 b' class APITest(NotebookTestBase):' | |||
|
71 | 74 | for dname in ['foo']: |
|
72 | 75 | shutil.rmtree(pjoin(nbdir, dname), ignore_errors=True) |
|
73 | 76 | |
|
77 | @onlyif_cmds_exist('pandoc') | |
|
74 | 78 | def test_from_file(self): |
|
75 | 79 | r = self.nbconvert_api.from_file('html', 'foo', 'testnb.ipynb') |
|
76 | 80 | self.assertEqual(r.status_code, 200) |
@@ -82,21 +86,25 b' class APITest(NotebookTestBase):' | |||
|
82 | 86 | self.assertIn(u'text/x-python', r.headers['Content-Type']) |
|
83 | 87 | self.assertIn(u'print(2*6)', r.text) |
|
84 | 88 | |
|
89 | @onlyif_cmds_exist('pandoc') | |
|
85 | 90 | def test_from_file_404(self): |
|
86 | 91 | with assert_http_error(404): |
|
87 | 92 | self.nbconvert_api.from_file('html', 'foo', 'thisdoesntexist.ipynb') |
|
88 | 93 | |
|
94 | @onlyif_cmds_exist('pandoc') | |
|
89 | 95 | def test_from_file_download(self): |
|
90 | 96 | r = self.nbconvert_api.from_file('python', 'foo', 'testnb.ipynb', download=True) |
|
91 | 97 | content_disposition = r.headers['Content-Disposition'] |
|
92 | 98 | self.assertIn('attachment', content_disposition) |
|
93 | 99 | self.assertIn('testnb.py', content_disposition) |
|
94 | 100 | |
|
101 | @onlyif_cmds_exist('pandoc') | |
|
95 | 102 | def test_from_file_zip(self): |
|
96 | 103 | r = self.nbconvert_api.from_file('latex', 'foo', 'testnb.ipynb', download=True) |
|
97 | 104 | self.assertIn(u'application/zip', r.headers['Content-Type']) |
|
98 | 105 | self.assertIn(u'.zip', r.headers['Content-Disposition']) |
|
99 | 106 | |
|
107 | @onlyif_cmds_exist('pandoc') | |
|
100 | 108 | def test_from_post(self): |
|
101 | 109 | nbmodel_url = url_path_join(self.base_url(), 'api/notebooks/foo/testnb.ipynb') |
|
102 | 110 | nbmodel = requests.get(nbmodel_url).json() |
@@ -111,6 +119,7 b' class APITest(NotebookTestBase):' | |||
|
111 | 119 | self.assertIn(u'text/x-python', r.headers['Content-Type']) |
|
112 | 120 | self.assertIn(u'print(2*6)', r.text) |
|
113 | 121 | |
|
122 | @onlyif_cmds_exist('pandoc') | |
|
114 | 123 | def test_from_post_zip(self): |
|
115 | 124 | nbmodel_url = url_path_join(self.base_url(), 'api/notebooks/foo/testnb.ipynb') |
|
116 | 125 | nbmodel = requests.get(nbmodel_url).json() |
@@ -280,6 +280,8 b" if not have['jinja2']:" | |||
|
280 | 280 | sec.exclude('notebookapp') |
|
281 | 281 | if not have['azure']: |
|
282 | 282 | sec.exclude('services.notebooks.azurenbmanager') |
|
283 | if not have['pygments'] or not have['jinja2']: | |
|
284 | sec.exclude('nbconvert') | |
|
283 | 285 | |
|
284 | 286 | # config: |
|
285 | 287 | # Config files aren't really importable stand-alone |
@@ -287,7 +289,7 b" test_sections['config'].exclude('profile')" | |||
|
287 | 289 | |
|
288 | 290 | # nbconvert: |
|
289 | 291 | sec = test_sections['nbconvert'] |
|
290 |
sec.requires('pygments', 'jinja2' |
|
|
292 | sec.requires('pygments', 'jinja2') | |
|
291 | 293 | # Exclude nbconvert directories containing config files used to test. |
|
292 | 294 | # Executing the config files with iptest would cause an exception. |
|
293 | 295 | sec.exclude('tests.files') |
General Comments 0
You need to be logged in to leave comments.
Login now