##// END OF EJS Templates
test upload of v2 notebooks
MinRK -
Show More
@@ -13,8 +13,10 b' import requests'
13
13
14 from IPython.html.utils import url_path_join, url_escape
14 from IPython.html.utils import url_path_join, url_escape
15 from IPython.html.tests.launchnotebook import NotebookTestBase, assert_http_error
15 from IPython.html.tests.launchnotebook import NotebookTestBase, assert_http_error
16 from IPython.nbformat import current
16 from IPython.nbformat.current import (new_notebook, write, read, new_worksheet,
17 from IPython.nbformat.current import (new_notebook, write, read, new_worksheet,
17 new_heading_cell, to_notebook_json)
18 new_heading_cell, to_notebook_json)
19 from IPython.nbformat import v2
18 from IPython.utils import py3compat
20 from IPython.utils import py3compat
19 from IPython.utils.data import uniq_stable
21 from IPython.utils.data import uniq_stable
20
22
@@ -194,6 +196,20 b' class APITest(NotebookTestBase):'
194 body=json.dumps(nbmodel))
196 body=json.dumps(nbmodel))
195 self._check_nb_created(resp, u'Upload tést.ipynb', u'å b')
197 self._check_nb_created(resp, u'Upload tést.ipynb', u'å b')
196
198
199 def test_upload_v2(self):
200 nb = v2.new_notebook()
201 ws = v2.new_worksheet()
202 nb.worksheets.append(ws)
203 ws.cells.append(v2.new_code_cell(input='print("hi")'))
204 nbmodel = {'content': nb}
205 resp = self.nb_api.upload(u'Upload tést.ipynb', path=u'å b',
206 body=json.dumps(nbmodel))
207 self._check_nb_created(resp, u'Upload tést.ipynb', u'å b')
208 resp = self.nb_api.read(u'Upload tést.ipynb', u'å b')
209 data = resp.json()
210 self.assertEqual(data['content']['nbformat'], current.nbformat)
211 self.assertEqual(data['content']['orig_nbformat'], 2)
212
197 def test_copy_untitled(self):
213 def test_copy_untitled(self):
198 resp = self.nb_api.copy_untitled(u'ç d.ipynb', path=u'å b')
214 resp = self.nb_api.copy_untitled(u'ç d.ipynb', path=u'å b')
199 self._check_nb_created(resp, u'ç d-Copy0.ipynb', u'å b')
215 self._check_nb_created(resp, u'ç d-Copy0.ipynb', u'å b')
@@ -293,3 +309,4 b' class APITest(NotebookTestBase):'
293 self.assertEqual(r.status_code, 204)
309 self.assertEqual(r.status_code, 204)
294 cps = self.nb_api.get_checkpoints('a.ipynb', 'foo').json()
310 cps = self.nb_api.get_checkpoints('a.ipynb', 'foo').json()
295 self.assertEqual(cps, [])
311 self.assertEqual(cps, [])
312
General Comments 0
You need to be logged in to leave comments. Login now