From 205eb857550f136854d949283aade50cc1d6820e 2013-11-06 01:43:36 From: Thomas Kluyver Date: 2013-11-06 01:43:36 Subject: [PATCH] Add test for saving notebook with .py script --- diff --git a/IPython/html/services/notebooks/tests/test_nbmanager.py b/IPython/html/services/notebooks/tests/test_nbmanager.py index 2135882..8d0adfa 100644 --- a/IPython/html/services/notebooks/tests/test_nbmanager.py +++ b/IPython/html/services/notebooks/tests/test_nbmanager.py @@ -196,6 +196,25 @@ class TestNotebookManager(TestCase): self.assertEqual(model['name'], 'Untitled0.ipynb') self.assertEqual(model['path'], sub_dir.strip('/')) + def test_save_notebook_with_script(self): + with TemporaryDirectory() as td: + # Create a notebook + nm = FileNotebookManager(notebook_dir=td) + nm.save_script = True + model = nm.create_notebook_model() + name = model['name'] + path = model['path'] + + # Get the model with 'content' + full_model = nm.get_notebook_model(name, path) + + # Save the notebook + model = nm.save_notebook_model(full_model, name, path) + + # Check that the script was created + py_path = os.path.join(td, os.path.splitext(name)[0]+'.py') + assert os.path.exists(py_path), py_path + def test_delete_notebook_model(self): with TemporaryDirectory() as td: # Test in the root directory