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