Add test for saving notebook with .py script

This commit is contained in:
Thomas Kluyver 2013-11-05 17:43:36 -08:00
parent 8ed3a725f3
commit b829043a60

View File

@ -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