##// END OF EJS Templates
TEST: Add test for renaming files with checkpoint....
Scott Sanderson -
Show More
@@ -508,6 +508,34 b' class APITest(NotebookTestBase):'
508 508 self.assertIn('z.ipynb', nbnames)
509 509 self.assertNotIn('a.ipynb', nbnames)
510 510
511 def test_rename_preserves_checkpoints(self):
512
513 # Read initial file state
514 orig = self.api.read('foo/a.ipynb')
515
516 # Create a checkpoint of initial state
517 r = self.api.new_checkpoint('foo/a.ipynb')
518 cp1 = r.json()
519
520 # Modify file and save
521 nbcontent = json.loads(orig.text)['content']
522 nb = from_dict(nbcontent)
523 hcell = new_markdown_cell('Created by test')
524 nb.cells.append(hcell)
525 nbmodel = {'content': nb, 'type': 'notebook'}
526 self.api.save('foo/a.ipynb', body=json.dumps(nbmodel))
527
528 # Rename the file.
529 self.api.rename('foo/a.ipynb', 'foo/z.ipynb')
530
531 # Looking for checkpoints in the old location should yield no results.
532 self.assertEqual(self.api.get_checkpoints('foo/a.ipynb').json(), [])
533
534 # Looking for checkpoints in the new location should work.
535 cps = self.api.get_checkpoints('foo/z.ipynb').json()
536 self.assertEqual(len(cps), 1)
537 self.assertEqual(cps[0], cp1)
538
511 539 def test_rename_existing(self):
512 540 with assert_http_error(409):
513 541 self.api.rename('foo/a.ipynb', 'foo/b.ipynb')
@@ -518,7 +546,7 b' class APITest(NotebookTestBase):'
518 546 nb = from_dict(nbcontent)
519 547 nb.cells.append(new_markdown_cell(u'Created by test ³'))
520 548
521 nbmodel= {'content': nb, 'type': 'notebook'}
549 nbmodel = {'content': nb, 'type': 'notebook'}
522 550 resp = self.api.save('foo/a.ipynb', body=json.dumps(nbmodel))
523 551
524 552 nbcontent = self.api.read('foo/a.ipynb').json()['content']
General Comments 0
You need to be logged in to leave comments. Login now