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:
Paul Ivanov 2013-08-12 19:53:28 -07:00 committed by MinRK
parent 18fdb26273
commit 11e5bd7b24

View File

@ -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/')