##// END OF EJS Templates
Backport PR #8102: TEST: Add test for renaming files with checkpoint....
Min RK -
Show More
@@ -508,6 +508,38 b' class APITest(NotebookTestBase):'
508 self.assertIn('z.ipynb', nbnames)
508 self.assertIn('z.ipynb', nbnames)
509 self.assertNotIn('a.ipynb', nbnames)
509 self.assertNotIn('a.ipynb', nbnames)
510
510
511 def test_checkpoints_follow_file(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(cps, [cp1])
537
538 # Delete the file. The checkpoint should be deleted as well.
539 self.api.delete('foo/z.ipynb')
540 cps = self.api.get_checkpoints('foo/z.ipynb').json()
541 self.assertEqual(cps, [])
542
511 def test_rename_existing(self):
543 def test_rename_existing(self):
512 with assert_http_error(409):
544 with assert_http_error(409):
513 self.api.rename('foo/a.ipynb', 'foo/b.ipynb')
545 self.api.rename('foo/a.ipynb', 'foo/b.ipynb')
@@ -518,7 +550,7 b' class APITest(NotebookTestBase):'
518 nb = from_dict(nbcontent)
550 nb = from_dict(nbcontent)
519 nb.cells.append(new_markdown_cell(u'Created by test ³'))
551 nb.cells.append(new_markdown_cell(u'Created by test ³'))
520
552
521 nbmodel= {'content': nb, 'type': 'notebook'}
553 nbmodel = {'content': nb, 'type': 'notebook'}
522 resp = self.api.save('foo/a.ipynb', body=json.dumps(nbmodel))
554 resp = self.api.save('foo/a.ipynb', body=json.dumps(nbmodel))
523
555
524 nbcontent = self.api.read('foo/a.ipynb').json()['content']
556 nbcontent = self.api.read('foo/a.ipynb').json()['content']
General Comments 0
You need to be logged in to leave comments. Login now