##// END OF EJS Templates
use from_dict for dict->notebook...
MinRK -
Show More
@@ -13,7 +13,7 b' from ..base.handlers import ('
13 13 IPythonHandler, FilesRedirectHandler,
14 14 notebook_path_regex, path_regex,
15 15 )
16 from IPython.nbformat.current import to_notebook_json
16 from IPython.nbformat.current import from_dict
17 17
18 18 from IPython.utils.py3compat import cast_bytes
19 19
@@ -115,7 +115,7 b' class NbconvertPostHandler(IPythonHandler):'
115 115
116 116 model = self.get_json_body()
117 117 name = model.get('name', 'notebook.ipynb')
118 nbnode = to_notebook_json(model['content'])
118 nbnode = from_dict(model['content'])
119 119
120 120 try:
121 121 output, resources = exporter.from_notebook_node(nbnode)
@@ -295,7 +295,7 b' class FileContentsManager(ContentsManager):'
295 295 def _save_notebook(self, os_path, model, name='', path=''):
296 296 """save a notebook file"""
297 297 # Save the notebook file
298 nb = current.to_notebook_json(model['content'])
298 nb = current.from_dict(model['content'])
299 299
300 300 self.check_and_sign(nb, name, path)
301 301
@@ -16,7 +16,7 b' from IPython.html.utils import url_path_join, url_escape'
16 16 from IPython.html.tests.launchnotebook import NotebookTestBase, assert_http_error
17 17 from IPython.nbformat import current
18 18 from IPython.nbformat.current import (new_notebook, write, read,
19 new_markdown_cell, to_notebook_json)
19 new_markdown_cell, from_dict)
20 20 from IPython.nbformat import v2
21 21 from IPython.utils import py3compat
22 22 from IPython.utils.data import uniq_stable
@@ -414,7 +414,7 b' class APITest(NotebookTestBase):'
414 414 def test_save(self):
415 415 resp = self.api.read('a.ipynb', 'foo')
416 416 nbcontent = json.loads(resp.text)['content']
417 nb = to_notebook_json(nbcontent)
417 nb = from_dict(nbcontent)
418 418 nb.cells.append(new_markdown_cell(u'Created by test ³'))
419 419
420 420 nbmodel= {'name': 'a.ipynb', 'path':'foo', 'content': nb, 'type': 'notebook'}
@@ -426,7 +426,7 b' class APITest(NotebookTestBase):'
426 426 self.assertEqual(newnb.cells[0].source,
427 427 u'Created by test ³')
428 428 nbcontent = self.api.read('a.ipynb', 'foo').json()['content']
429 newnb = to_notebook_json(nbcontent)
429 newnb = from_dict(nbcontent)
430 430 self.assertEqual(newnb.cells[0].source,
431 431 u'Created by test ³')
432 432
@@ -451,7 +451,7 b' class APITest(NotebookTestBase):'
451 451
452 452 # Modify it
453 453 nbcontent = json.loads(resp.text)['content']
454 nb = to_notebook_json(nbcontent)
454 nb = from_dict(nbcontent)
455 455 hcell = new_markdown_cell('Created by test')
456 456 nb.cells.append(hcell)
457 457 # Save
@@ -463,14 +463,14 b' class APITest(NotebookTestBase):'
463 463 self.assertEqual(cps, [cp1])
464 464
465 465 nbcontent = self.api.read('a.ipynb', 'foo').json()['content']
466 nb = to_notebook_json(nbcontent)
466 nb = from_dict(nbcontent)
467 467 self.assertEqual(nb.cells[0].source, 'Created by test')
468 468
469 469 # Restore cp1
470 470 r = self.api.restore_checkpoint('a.ipynb', 'foo', cp1['id'])
471 471 self.assertEqual(r.status_code, 204)
472 472 nbcontent = self.api.read('a.ipynb', 'foo').json()['content']
473 nb = to_notebook_json(nbcontent)
473 nb = from_dict(nbcontent)
474 474 self.assertEqual(nb.cells, [])
475 475
476 476 # Delete cp1
General Comments 0
You need to be logged in to leave comments. Login now