From 08ff7191fd26a43c798139af27d43bcc5e97d84c 2015-03-23 22:59:14 From: Scott Sanderson Date: 2015-03-23 22:59:14 Subject: [PATCH] TEST: Add test for handling of last_modified. Saving should increment last_modified. Renaming should not. Noticed because incrementing last_modified on rename results in a scary error message from the frontend. --- diff --git a/IPython/html/services/contents/tests/test_manager.py b/IPython/html/services/contents/tests/test_manager.py index 73bf522..99fbb92 100644 --- a/IPython/html/services/contents/tests/test_manager.py +++ b/IPython/html/services/contents/tests/test_manager.py @@ -257,6 +257,30 @@ class TestContentsManager(TestCase): self.assertEqual(model['name'], 'untitled') self.assertEqual(model['path'], '%s/untitled' % sub_dir) + def test_modified_date(self): + + cm = self.contents_manager + + # Create a new notebook. + nb, name, path = self.new_notebook() + model = cm.get(path) + + # Add a cell and save. + self.add_code_cell(model['content']) + cm.save(model, path) + + # Reload notebook and verify that last_modified incremented. + saved = cm.get(path) + self.assertGreater(saved['last_modified'], model['last_modified']) + + # Move the notebook and verify that last_modified stayed the same. + # (The frontend fires a warning if last_modified increases on the + # renamed file.) + new_path = 'renamed.ipynb' + cm.rename(path, new_path) + renamed = cm.get(new_path) + self.assertEqual(renamed['last_modified'], saved['last_modified']) + def test_get(self): cm = self.contents_manager # Create a notebook