From 11e5bd7b2469506b7eb6214e7fdffe0e561e43b2 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Mon, 12 Aug 2013 19:53:28 -0700 Subject: [PATCH] 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. --- .../notebooks/tests/test_nbmanager.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/IPython/html/services/notebooks/tests/test_nbmanager.py b/IPython/html/services/notebooks/tests/test_nbmanager.py index 54aa0e937..3a745ca19 100644 --- a/IPython/html/services/notebooks/tests/test_nbmanager.py +++ b/IPython/html/services/notebooks/tests/test_nbmanager.py @@ -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/') +