mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Merge pull request #8126 from quantopian/test-modified-date
TEST: Add test for handling of last_modified.
This commit is contained in:
commit
191185c84d
@ -257,6 +257,33 @@ class TestContentsManager(TestCase):
|
|||||||
self.assertEqual(model['name'], 'untitled')
|
self.assertEqual(model['name'], 'untitled')
|
||||||
self.assertEqual(model['path'], '%s/untitled' % sub_dir)
|
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.assertGreaterEqual(
|
||||||
|
renamed['last_modified'],
|
||||||
|
saved['last_modified'],
|
||||||
|
)
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
cm = self.contents_manager
|
cm = self.contents_manager
|
||||||
# Create a notebook
|
# Create a notebook
|
||||||
|
Loading…
Reference in New Issue
Block a user