Show More
@@ -508,6 +508,34 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_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 | def test_rename_existing(self): |
|
539 | def test_rename_existing(self): | |
512 | with assert_http_error(409): |
|
540 | with assert_http_error(409): | |
513 | self.api.rename('foo/a.ipynb', 'foo/b.ipynb') |
|
541 | self.api.rename('foo/a.ipynb', 'foo/b.ipynb') |
General Comments 0
You need to be logged in to leave comments.
Login now