mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
adding tests for named_notebook_path
I want to do some refactoring, so I'll put in some tests that will define the behavior that I want to preserve, so I can verify that my refactoring hasn't broken anything.
This commit is contained in:
parent
18fdb26273
commit
11e5bd7b24
@ -8,8 +8,9 @@ from IPython.utils.tempdir import TemporaryDirectory
|
||||
from IPython.utils.traitlets import TraitError
|
||||
|
||||
from ..filenbmanager import FileNotebookManager
|
||||
from ..nbmanager import NotebookManager
|
||||
|
||||
class TestNotebookManager(TestCase):
|
||||
class TestFileNotebookManager(TestCase):
|
||||
|
||||
def test_nb_dir(self):
|
||||
with TemporaryDirectory() as td:
|
||||
@ -31,4 +32,21 @@ class TestNotebookManager(TestCase):
|
||||
with NamedTemporaryFile() as tf:
|
||||
self.assertRaises(TraitError, FileNotebookManager, notebook_dir=tf.name)
|
||||
|
||||
class TestNotebookManager(TestCase):
|
||||
def test_named_notebook_path(self):
|
||||
nm = NotebookManager()
|
||||
|
||||
# doesn't end with ipynb, should just be path
|
||||
name, path = nm.named_notebook_path('hello')
|
||||
self.assertEqual(name, None)
|
||||
self.assertEqual(path, 'hello/')
|
||||
|
||||
name, path = nm.named_notebook_path('hello.ipynb')
|
||||
self.assertEqual(name, 'hello.ipynb')
|
||||
self.assertEqual(path, None)
|
||||
|
||||
name, path = nm.named_notebook_path('/this/is/a/path/hello.ipynb')
|
||||
self.assertEqual(name, 'hello.ipynb')
|
||||
self.assertEqual(path, '/this/is/a/path/')
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user