##// END OF EJS Templates
TEST: Test separate roots for Contents and Checkpoints.
Scott Sanderson -
Show More
@@ -2,6 +2,7 b''
2 2 """Test the contents webservice API."""
3 3
4 4 import base64
5 from contextlib import contextmanager
5 6 import io
6 7 import json
7 8 import os
@@ -21,6 +22,7 b' from IPython.nbformat.v4 import ('
21 22 from IPython.nbformat import v2
22 23 from IPython.utils import py3compat
23 24 from IPython.utils.data import uniq_stable
25 from IPython.utils.tempdir import TemporaryDirectory
24 26
25 27
26 28 def notebooks_only(dir_model):
@@ -502,7 +504,6 b' class APITest(NotebookTestBase):'
502 504 self.assertEqual(newnb.cells[0].source,
503 505 u'Created by test ³')
504 506
505
506 507 def test_checkpoints(self):
507 508 resp = self.api.read('foo/a.ipynb')
508 509 r = self.api.new_checkpoint('foo/a.ipynb')
@@ -540,3 +541,28 b' class APITest(NotebookTestBase):'
540 541 self.assertEqual(r.status_code, 204)
541 542 cps = self.api.get_checkpoints('foo/a.ipynb').json()
542 543 self.assertEqual(cps, [])
544
545 @contextmanager
546 def patch_cp_root(self, dirname):
547 """
548 Temporarily patch the root dir of our checkpoint manager.
549 """
550 cpm = self.notebook.contents_manager.checkpoint_manager
551 old_dirname = cpm.root_dir
552 cpm.root_dir = dirname
553 try:
554 yield
555 finally:
556 cpm.root_dir = old_dirname
557
558 def test_checkpoints_separate_root(self):
559 """
560 Test that FileCheckpointManager functions correctly even when it's
561 using a different root dir from FileContentsManager. This also keeps
562 the implementation honest for use with ContentsManagers that don't map
563 models to the filesystem
564 """
565
566 with TemporaryDirectory() as td:
567 with self.patch_cp_root(td):
568 self.test_checkpoints()
General Comments 0
You need to be logged in to leave comments. Login now