##// END OF EJS Templates
fix github milestone link
fix github milestone link

File last commit:

r19839:6ab8853b
r20443:f6509fc5
Show More
test_manager.py
441 lines | 15.3 KiB | text/x-python | PythonLexer
MinRK
test nbmanager.copy_notebook
r13136 # coding: utf-8
MinRK
add tests for notebook_dir validation
r7637 """Tests for the notebook manager."""
Thomas Kluyver
Convert print statements to print function calls...
r13348 from __future__ import print_function
MinRK
add tests for notebook_dir validation
r7637
import os
Min RK
add counter to new notebooks in test_manager...
r19628 import time
Zachary Sailer
refactoring of nbmanager and filenbmanager...
r13046
from tornado.web import HTTPError
MinRK
add tests for notebook_dir validation
r7637 from unittest import TestCase
from tempfile import NamedTemporaryFile
MinRK
don't use nbformat.current in IPython.html...
r18607 from IPython.nbformat import v4 as nbformat
MinRK
Add Trust Notebook to File menu
r15655
MinRK
add tests for notebook_dir validation
r7637 from IPython.utils.tempdir import TemporaryDirectory
from IPython.utils.traitlets import TraitError
Zachary Sailer
refactoring of nbmanager and filenbmanager...
r13046 from IPython.html.utils import url_path_join
MinRK
fix directory listing with broken symlinks...
r17710 from IPython.testing import decorators as dec
MinRK
add tests for notebook_dir validation
r7637
MinRK
rename notebooks service to contents service...
r17524 from ..filemanager import FileContentsManager
MinRK
add tests for notebook_dir validation
r7637
Brian E. Granger
Get the existing tests working.
r15079
Scott Sanderson
TEST: Refactor symlink tests.
r19612 def _make_dir(contents_manager, api_path):
"""
Make a directory.
"""
os_path = contents_manager._get_os_path(api_path)
try:
os.makedirs(os_path)
except OSError:
print("Directory already exists: %r" % os_path)
MinRK
rename notebooks service to contents service...
r17524 class TestFileContentsManager(TestCase):
MinRK
add tests for notebook_dir validation
r7637
Scott Sanderson
TEST: Refactor symlink tests.
r19612 def symlink(self, contents_manager, src, dst):
Min RK
move symlink tests to TestFileManager
r19611 """Make a symlink to src from dst
src and dst are api_paths
"""
Scott Sanderson
TEST: Refactor symlink tests.
r19612 src_os_path = contents_manager._get_os_path(src)
dst_os_path = contents_manager._get_os_path(dst)
Min RK
move symlink tests to TestFileManager
r19611 print(src_os_path, dst_os_path, os.path.isfile(src_os_path))
os.symlink(src_os_path, dst_os_path)
MinRK
rename notebooks service to contents service...
r17524 def test_root_dir(self):
MinRK
add tests for notebook_dir validation
r7637 with TemporaryDirectory() as td:
MinRK
rename notebooks service to contents service...
r17524 fm = FileContentsManager(root_dir=td)
self.assertEqual(fm.root_dir, td)
MinRK
add tests for notebook_dir validation
r7637
MinRK
rename notebooks service to contents service...
r17524 def test_missing_root_dir(self):
MinRK
add tests for notebook_dir validation
r7637 with TemporaryDirectory() as td:
MinRK
rename notebooks service to contents service...
r17524 root = os.path.join(td, 'notebook', 'dir', 'is', 'missing')
self.assertRaises(TraitError, FileContentsManager, root_dir=root)
MinRK
add tests for notebook_dir validation
r7637
MinRK
rename notebooks service to contents service...
r17524 def test_invalid_root_dir(self):
MinRK
add tests for notebook_dir validation
r7637 with NamedTemporaryFile() as tf:
MinRK
rename notebooks service to contents service...
r17524 self.assertRaises(TraitError, FileContentsManager, root_dir=tf.name)
MinRK
add tests for notebook_dir validation
r7637
Zachary Sailer
handle path separators with os.sep and add tests...
r13032 def test_get_os_path(self):
# full filesystem path should be returned with correct operating system
# separators.
with TemporaryDirectory() as td:
MinRK
rename notebooks service to contents service...
r17524 root = td
fm = FileContentsManager(root_dir=root)
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 path = fm._get_os_path('/path/to/notebook/test.ipynb')
Paul Ivanov
clean up of get_os_path and its tests...
r13034 rel_path_list = '/path/to/notebook/test.ipynb'.split('/')
MinRK
rename notebooks service to contents service...
r17524 fs_path = os.path.join(fm.root_dir, *rel_path_list)
Paul Ivanov
clean up of get_os_path and its tests...
r13034 self.assertEqual(path, fs_path)
MinRK
rename notebooks service to contents service...
r17524 fm = FileContentsManager(root_dir=root)
MinRK
reorganize who knows what about paths...
r15420 path = fm._get_os_path('test.ipynb')
MinRK
rename notebooks service to contents service...
r17524 fs_path = os.path.join(fm.root_dir, 'test.ipynb')
Paul Ivanov
clean up of get_os_path and its tests...
r13034 self.assertEqual(path, fs_path)
MinRK
rename notebooks service to contents service...
r17524 fm = FileContentsManager(root_dir=root)
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 path = fm._get_os_path('////test.ipynb')
MinRK
rename notebooks service to contents service...
r17524 fs_path = os.path.join(fm.root_dir, 'test.ipynb')
Paul Ivanov
clean up of get_os_path and its tests...
r13034 self.assertEqual(path, fs_path)
MinRK
mv services/notebooks services/contents
r17523
MinRK
test notebook checkpoints in subdirectories
r16440 def test_checkpoint_subdir(self):
subd = u'sub ∂ir'
cp_name = 'test-cp.ipynb'
with TemporaryDirectory() as td:
MinRK
rename notebooks service to contents service...
r17524 root = td
MinRK
test notebook checkpoints in subdirectories
r16440 os.mkdir(os.path.join(td, subd))
MinRK
rename notebooks service to contents service...
r17524 fm = FileContentsManager(root_dir=root)
Scott Sanderson
STY: s/CheckpointManager/Checkpoints...
r19839 cpm = fm.checkpoints
Scott Sanderson
DEV: Add full support for non-notebook checkpoints.
r19786 cp_dir = cpm.checkpoint_path(
Scott Sanderson
DEV: Refactor checkpoint logic from FileContentsManager....
r19727 'cp', 'test.ipynb'
)
Scott Sanderson
DEV: Add full support for non-notebook checkpoints.
r19786 cp_subdir = cpm.checkpoint_path(
Scott Sanderson
DEV: Refactor checkpoint logic from FileContentsManager....
r19727 'cp', '/%s/test.ipynb' % subd
)
MinRK
test notebook checkpoints in subdirectories
r16440 self.assertNotEqual(cp_dir, cp_subdir)
Scott Sanderson
DEV: Refactor checkpoint logic from FileContentsManager....
r19727 self.assertEqual(cp_dir, os.path.join(root, cpm.checkpoint_dir, cp_name))
self.assertEqual(cp_subdir, os.path.join(root, subd, cpm.checkpoint_dir, cp_name))
Min RK
move symlink tests to TestFileManager
r19611
@dec.skip_win32
def test_bad_symlink(self):
Scott Sanderson
TEST: Refactor symlink tests.
r19612 with TemporaryDirectory() as td:
cm = FileContentsManager(root_dir=td)
path = 'test bad symlink'
_make_dir(cm, path)
file_model = cm.new_untitled(path=path, ext='.txt')
# create a broken symlink
self.symlink(cm, "target", '%s/%s' % (path, 'bad symlink'))
model = cm.get(path)
self.assertEqual(model['content'], [file_model])
Min RK
move symlink tests to TestFileManager
r19611
@dec.skip_win32
def test_good_symlink(self):
Scott Sanderson
TEST: Refactor symlink tests.
r19612 with TemporaryDirectory() as td:
cm = FileContentsManager(root_dir=td)
parent = 'test good symlink'
name = 'good symlink'
path = '{0}/{1}'.format(parent, name)
_make_dir(cm, parent)
file_model = cm.new(path=parent + '/zfoo.txt')
# create a good symlink
self.symlink(cm, file_model['path'], path)
symlink_model = cm.get(path, content=False)
dir_model = cm.get(parent)
self.assertEqual(
sorted(dir_model['content'], key=lambda x: x['name']),
[symlink_model, file_model],
)
MinRK
mv services/notebooks services/contents
r17523
Zachary Sailer
handle path separators with os.sep and add tests...
r13032
MinRK
teach contents service about non-notebook files
r17525 class TestContentsManager(TestCase):
Min RK
abstract some methods in contents service tests...
r19604
MinRK
Add Trust Notebook to File menu
r15655 def setUp(self):
self._temp_dir = TemporaryDirectory()
self.td = self._temp_dir.name
MinRK
rename notebooks service to contents service...
r17524 self.contents_manager = FileContentsManager(
root_dir=self.td,
MinRK
cleanup test_nbmanager...
r15656 )
MinRK
mv services/notebooks services/contents
r17523
MinRK
Add Trust Notebook to File menu
r15655 def tearDown(self):
self._temp_dir.cleanup()
MinRK
mv services/notebooks services/contents
r17523
Min RK
abstract some methods in contents service tests...
r19604 def make_dir(self, api_path):
Min RK
docstring on test_dir
r19674 """make a subdirectory at api_path
override in subclasses if contents are not on the filesystem.
"""
Scott Sanderson
TEST: Refactor symlink tests.
r19612 _make_dir(self.contents_manager, api_path)
MinRK
mv services/notebooks services/contents
r17523
MinRK
Add Trust Notebook to File menu
r15655 def add_code_cell(self, nb):
MinRK
don't use nbformat.current in IPython.html...
r18607 output = nbformat.new_output("display_data", {'application/javascript': "alert('hi');"})
cell = nbformat.new_code_cell("print('hi')", outputs=[output])
MinRK
update html/js to nbformat 4
r18584 nb.cells.append(cell)
MinRK
mv services/notebooks services/contents
r17523
MinRK
Add Trust Notebook to File menu
r15655 def new_notebook(self):
MinRK
rename notebooks service to contents service...
r17524 cm = self.contents_manager
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 model = cm.new_untitled(type='notebook')
MinRK
Add Trust Notebook to File menu
r15655 name = model['name']
path = model['path']
MinRK
mv services/notebooks services/contents
r17523
Thomas Kluyver
Rename get_model() to get()
r18791 full_model = cm.get(path)
MinRK
Add Trust Notebook to File menu
r15655 nb = full_model['content']
Min RK
add counter to new notebooks in test_manager...
r19628 nb['metadata']['counter'] = int(1e6 * time.time())
MinRK
Add Trust Notebook to File menu
r15655 self.add_code_cell(nb)
MinRK
mv services/notebooks services/contents
r17523
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 cm.save(full_model, path)
MinRK
Add Trust Notebook to File menu
r15655 return nb, name, path
MinRK
mv services/notebooks services/contents
r17523
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 def test_new_untitled(self):
MinRK
rename notebooks service to contents service...
r17524 cm = self.contents_manager
MinRK
cleanup test_nbmanager...
r15656 # Test in root directory
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 model = cm.new_untitled(type='notebook')
MinRK
cleanup test_nbmanager...
r15656 assert isinstance(model, dict)
self.assertIn('name', model)
self.assertIn('path', model)
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 self.assertIn('type', model)
self.assertEqual(model['type'], 'notebook')
Min RK
adjustments to filename increment...
r18813 self.assertEqual(model['name'], 'Untitled.ipynb')
self.assertEqual(model['path'], 'Untitled.ipynb')
MinRK
cleanup test_nbmanager...
r15656
# Test in sub-directory
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 model = cm.new_untitled(type='directory')
MinRK
cleanup test_nbmanager...
r15656 assert isinstance(model, dict)
self.assertIn('name', model)
self.assertIn('path', model)
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 self.assertIn('type', model)
self.assertEqual(model['type'], 'directory')
Min RK
adjustments to filename increment...
r18813 self.assertEqual(model['name'], 'Untitled Folder')
self.assertEqual(model['path'], 'Untitled Folder')
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 sub_dir = model['path']
model = cm.new_untitled(path=sub_dir)
assert isinstance(model, dict)
self.assertIn('name', model)
self.assertIn('path', model)
self.assertIn('type', model)
self.assertEqual(model['type'], 'file')
Min RK
adjustments to filename increment...
r18813 self.assertEqual(model['name'], 'untitled')
self.assertEqual(model['path'], '%s/untitled' % sub_dir)
Zachary Sailer
refactoring of nbmanager and filenbmanager...
r13046
MinRK
rename notebooks service to contents service...
r17524 def test_get(self):
cm = self.contents_manager
MinRK
cleanup test_nbmanager...
r15656 # Create a notebook
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 model = cm.new_untitled(type='notebook')
MinRK
cleanup test_nbmanager...
r15656 name = model['name']
path = model['path']
# Check that we 'get' on the notebook we just created
Thomas Kluyver
Rename get_model() to get()
r18791 model2 = cm.get(path)
MinRK
cleanup test_nbmanager...
r15656 assert isinstance(model2, dict)
self.assertIn('name', model2)
self.assertIn('path', model2)
self.assertEqual(model['name'], name)
self.assertEqual(model['path'], path)
Min RK
ContentsManager type kwarg to match model key...
r19391 nb_as_file = cm.get(path, content=True, type='file')
Thomas Kluyver
Add type parameter for contents GET requests
r18781 self.assertEqual(nb_as_file['path'], path)
self.assertEqual(nb_as_file['type'], 'file')
self.assertEqual(nb_as_file['format'], 'text')
self.assertNotIsInstance(nb_as_file['content'], dict)
Min RK
ContentsManager type kwarg to match model key...
r19391 nb_as_bin_file = cm.get(path, content=True, type='file', format='base64')
Thomas Kluyver
Allow specifying format when getting files from contents API
r18788 self.assertEqual(nb_as_bin_file['format'], 'base64')
MinRK
cleanup test_nbmanager...
r15656 # Test in sub-directory
sub_dir = '/foo/'
Min RK
abstract some methods in contents service tests...
r19604 self.make_dir('foo')
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 model = cm.new_untitled(path=sub_dir, ext='.ipynb')
Thomas Kluyver
Rename get_model() to get()
r18791 model2 = cm.get(sub_dir + name)
MinRK
cleanup test_nbmanager...
r15656 assert isinstance(model2, dict)
self.assertIn('name', model2)
self.assertIn('path', model2)
self.assertIn('content', model2)
Min RK
adjustments to filename increment...
r18813 self.assertEqual(model2['name'], 'Untitled.ipynb')
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 self.assertEqual(model2['path'], '{0}/{1}'.format(sub_dir.strip('/'), name))
Thomas Kluyver
Add type parameter for contents GET requests
r18781
Scott Sanderson
TEST: Add a non-notebook file to directory test.
r19618 # Test with a regular file.
file_model_path = cm.new_untitled(path=sub_dir, ext='.txt')['path']
file_model = cm.get(file_model_path)
self.assertDictContainsSubset(
{
'content': u'',
Scott Sanderson
MAINT: Unicode literal in assertDictContainsSubset
r19619 'format': u'text',
Scott Sanderson
TEST: Add a non-notebook file to directory test.
r19618 'mimetype': u'text/plain',
'name': u'untitled.txt',
'path': u'foo/untitled.txt',
'type': u'file',
'writable': True,
},
file_model,
)
self.assertIn('created', file_model)
self.assertIn('last_modified', file_model)
Thomas Kluyver
Add type parameter for contents GET requests
r18781 # Test getting directory model
Scott Sanderson
TEST: More fine-grained test for directory contents....
r19609
# Create a sub-sub directory to test getting directory contents with a
# subdir.
Scott Sanderson
TEST: Add checks for subdirectory name splitting....
r19610 self.make_dir('foo/bar')
Thomas Kluyver
Rename get_model() to get()
r18791 dirmodel = cm.get('foo')
Thomas Kluyver
Add type parameter for contents GET requests
r18781 self.assertEqual(dirmodel['type'], 'directory')
Scott Sanderson
TEST: More fine-grained test for directory contents....
r19609 self.assertIsInstance(dirmodel['content'], list)
Scott Sanderson
TEST: Add a non-notebook file to directory test.
r19618 self.assertEqual(len(dirmodel['content']), 3)
Scott Sanderson
TEST: Add checks for subdirectory name splitting....
r19610 self.assertEqual(dirmodel['path'], 'foo')
self.assertEqual(dirmodel['name'], 'foo')
Scott Sanderson
TEST: More fine-grained test for directory contents....
r19609
# Directory contents should match the contents of each individual entry
# when requested with content=False.
model2_no_content = cm.get(sub_dir + name, content=False)
Scott Sanderson
TEST: Add a non-notebook file to directory test.
r19618 file_model_no_content = cm.get(u'foo/untitled.txt', content=False)
Scott Sanderson
TEST: Add checks for subdirectory name splitting....
r19610 sub_sub_dir_no_content = cm.get('foo/bar', content=False)
self.assertEqual(sub_sub_dir_no_content['path'], 'foo/bar')
self.assertEqual(sub_sub_dir_no_content['name'], 'bar')
Scott Sanderson
TEST: More fine-grained test for directory contents....
r19609 for entry in dirmodel['content']:
# Order isn't guaranteed by the spec, so this is a hacky way of
# verifying that all entries are matched.
if entry['path'] == sub_sub_dir_no_content['path']:
self.assertEqual(entry, sub_sub_dir_no_content)
elif entry['path'] == model2_no_content['path']:
self.assertEqual(entry, model2_no_content)
Scott Sanderson
TEST: Add a non-notebook file to directory test.
r19618 elif entry['path'] == file_model_no_content['path']:
self.assertEqual(entry, file_model_no_content)
Scott Sanderson
TEST: More fine-grained test for directory contents....
r19609 else:
self.fail("Unexpected directory entry: %s" % entry())
Thomas Kluyver
Add type parameter for contents GET requests
r18781
with self.assertRaises(HTTPError):
Min RK
ContentsManager type kwarg to match model key...
r19391 cm.get('foo', type='file')
Thomas Kluyver
Add type parameter for contents GET requests
r18781
MinRK
rename notebooks service to contents service...
r17524 def test_update(self):
cm = self.contents_manager
MinRK
cleanup test_nbmanager...
r15656 # Create a notebook
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 model = cm.new_untitled(type='notebook')
MinRK
cleanup test_nbmanager...
r15656 name = model['name']
path = model['path']
# Change the name in the model for rename
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 model['path'] = 'test.ipynb'
model = cm.update(model, path)
MinRK
cleanup test_nbmanager...
r15656 assert isinstance(model, dict)
self.assertIn('name', model)
self.assertIn('path', model)
self.assertEqual(model['name'], 'test.ipynb')
# Make sure the old name is gone
Thomas Kluyver
Rename get_model() to get()
r18791 self.assertRaises(HTTPError, cm.get, path)
MinRK
cleanup test_nbmanager...
r15656
# Test in sub-directory
# Create a directory and notebook in that directory
sub_dir = '/foo/'
Min RK
abstract some methods in contents service tests...
r19604 self.make_dir('foo')
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 model = cm.new_untitled(path=sub_dir, type='notebook')
MinRK
cleanup test_nbmanager...
r15656 path = model['path']
MinRK
mv services/notebooks services/contents
r17523
MinRK
cleanup test_nbmanager...
r15656 # Change the name in the model for rename
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 d = path.rsplit('/', 1)[0]
new_path = model['path'] = d + '/test_in_sub.ipynb'
model = cm.update(model, path)
MinRK
cleanup test_nbmanager...
r15656 assert isinstance(model, dict)
self.assertIn('name', model)
self.assertIn('path', model)
self.assertEqual(model['name'], 'test_in_sub.ipynb')
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 self.assertEqual(model['path'], new_path)
MinRK
mv services/notebooks services/contents
r17523
MinRK
cleanup test_nbmanager...
r15656 # Make sure the old name is gone
Thomas Kluyver
Rename get_model() to get()
r18791 self.assertRaises(HTTPError, cm.get, path)
Zachary Sailer
refactoring of nbmanager and filenbmanager...
r13046
MinRK
rename notebooks service to contents service...
r17524 def test_save(self):
cm = self.contents_manager
MinRK
cleanup test_nbmanager...
r15656 # Create a notebook
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 model = cm.new_untitled(type='notebook')
MinRK
cleanup test_nbmanager...
r15656 name = model['name']
path = model['path']
# Get the model with 'content'
Thomas Kluyver
Rename get_model() to get()
r18791 full_model = cm.get(path)
MinRK
cleanup test_nbmanager...
r15656
# Save the notebook
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 model = cm.save(full_model, path)
MinRK
cleanup test_nbmanager...
r15656 assert isinstance(model, dict)
self.assertIn('name', model)
self.assertIn('path', model)
self.assertEqual(model['name'], name)
self.assertEqual(model['path'], path)
# Test in sub-directory
# Create a directory and notebook in that directory
sub_dir = '/foo/'
Min RK
abstract some methods in contents service tests...
r19604 self.make_dir('foo')
Min RK
split ContentsManager.new, add ContentsManager.new_untitled
r18759 model = cm.new_untitled(path=sub_dir, type='notebook')
MinRK
cleanup test_nbmanager...
r15656 name = model['name']
path = model['path']
Thomas Kluyver
Rename get_model() to get()
r18791 model = cm.get(path)
MinRK
cleanup test_nbmanager...
r15656
# Change the name in the model for rename
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 model = cm.save(model, path)
MinRK
cleanup test_nbmanager...
r15656 assert isinstance(model, dict)
self.assertIn('name', model)
self.assertIn('path', model)
Min RK
adjustments to filename increment...
r18813 self.assertEqual(model['name'], 'Untitled.ipynb')
self.assertEqual(model['path'], 'foo/Untitled.ipynb')
Zachary Sailer
refactoring of nbmanager and filenbmanager...
r13046
MinRK
rename notebooks service to contents service...
r17524 def test_delete(self):
cm = self.contents_manager
MinRK
cleanup test_nbmanager...
r15656 # Create a notebook
nb, name, path = self.new_notebook()
MinRK
mv services/notebooks services/contents
r17523
MinRK
cleanup test_nbmanager...
r15656 # Delete the notebook
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 cm.delete(path)
MinRK
mv services/notebooks services/contents
r17523
Scott Sanderson
TEST: Expect a 404 on delete of non-existent file.
r19608 # Check that deleting a non-existent path raises an error.
self.assertRaises(HTTPError, cm.delete, path)
MinRK
cleanup test_nbmanager...
r15656 # Check that a 'get' on the deleted notebook raises and error
Thomas Kluyver
Rename get_model() to get()
r18791 self.assertRaises(HTTPError, cm.get, path)
MinRK
mv services/notebooks services/contents
r17523
MinRK
rename notebooks service to contents service...
r17524 def test_copy(self):
cm = self.contents_manager
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 parent = u'Ã¥ b'
MinRK
cleanup test_nbmanager...
r15656 name = u'nb √.ipynb'
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 path = u'{0}/{1}'.format(parent, name)
Min RK
abstract some methods in contents service tests...
r19604 self.make_dir(parent)
MinRK
mv services/notebooks services/contents
r17523
Scott Sanderson
TEST: Expect a 404 on delete of non-existent file.
r19608 orig = cm.new(path=path)
MinRK
cleanup test_nbmanager...
r15656 # copy with unspecified name
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 copy = cm.copy(path)
Min RK
adjustments to filename increment...
r18813 self.assertEqual(copy['name'], orig['name'].replace('.ipynb', '-Copy1.ipynb'))
MinRK
mv services/notebooks services/contents
r17523
MinRK
cleanup test_nbmanager...
r15656 # copy with specified name
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 copy2 = cm.copy(path, u'Ã¥ b/copy 2.ipynb')
MinRK
cleanup test_nbmanager...
r15656 self.assertEqual(copy2['name'], u'copy 2.ipynb')
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 self.assertEqual(copy2['path'], u'Ã¥ b/copy 2.ipynb')
Min RK
adjustments to filename increment...
r18813 # copy with specified path
copy2 = cm.copy(path, u'/')
self.assertEqual(copy2['name'], name)
self.assertEqual(copy2['path'], name)
MinRK
mv services/notebooks services/contents
r17523
MinRK
Add Trust Notebook to File menu
r15655 def test_trust_notebook(self):
MinRK
rename notebooks service to contents service...
r17524 cm = self.contents_manager
MinRK
Add Trust Notebook to File menu
r15655 nb, name, path = self.new_notebook()
MinRK
mv services/notebooks services/contents
r17523
Thomas Kluyver
Rename get_model() to get()
r18791 untrusted = cm.get(path)['content']
MinRK
rename notebooks service to contents service...
r17524 assert not cm.notary.check_cells(untrusted)
MinRK
mv services/notebooks services/contents
r17523
MinRK
cleanup test_nbmanager...
r15656 # print(untrusted)
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 cm.trust_notebook(path)
Thomas Kluyver
Rename get_model() to get()
r18791 trusted = cm.get(path)['content']
MinRK
cleanup test_nbmanager...
r15656 # print(trusted)
MinRK
rename notebooks service to contents service...
r17524 assert cm.notary.check_cells(trusted)
MinRK
mv services/notebooks services/contents
r17523
MinRK
Add Trust Notebook to File menu
r15655 def test_mark_trusted_cells(self):
MinRK
rename notebooks service to contents service...
r17524 cm = self.contents_manager
MinRK
Add Trust Notebook to File menu
r15655 nb, name, path = self.new_notebook()
MinRK
mv services/notebooks services/contents
r17523
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 cm.mark_trusted_cells(nb, path)
MinRK
update html/js to nbformat 4
r18584 for cell in nb.cells:
MinRK
Add Trust Notebook to File menu
r15655 if cell.cell_type == 'code':
MinRK
trust is stored in code_cell.metadata...
r18255 assert not cell.metadata.trusted
MinRK
mv services/notebooks services/contents
r17523
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 cm.trust_notebook(path)
Thomas Kluyver
Rename get_model() to get()
r18791 nb = cm.get(path)['content']
MinRK
update html/js to nbformat 4
r18584 for cell in nb.cells:
MinRK
Add Trust Notebook to File menu
r15655 if cell.cell_type == 'code':
MinRK
trust is stored in code_cell.metadata...
r18255 assert cell.metadata.trusted
MinRK
Add Trust Notebook to File menu
r15655
def test_check_and_sign(self):
MinRK
rename notebooks service to contents service...
r17524 cm = self.contents_manager
MinRK
Add Trust Notebook to File menu
r15655 nb, name, path = self.new_notebook()
MinRK
mv services/notebooks services/contents
r17523
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 cm.mark_trusted_cells(nb, path)
cm.check_and_sign(nb, path)
MinRK
rename notebooks service to contents service...
r17524 assert not cm.notary.check_signature(nb)
MinRK
mv services/notebooks services/contents
r17523
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 cm.trust_notebook(path)
Thomas Kluyver
Rename get_model() to get()
r18791 nb = cm.get(path)['content']
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 cm.mark_trusted_cells(nb, path)
cm.check_and_sign(nb, path)
MinRK
rename notebooks service to contents service...
r17524 assert cm.notary.check_signature(nb)
Min RK
move symlink tests to TestFileManager
r19611