Show More
@@ -153,6 +153,8 b' class FileNotebookManager(NotebookManager):' | |||
|
153 | 153 | nbpath = self.get_os_path(name, path=path) |
|
154 | 154 | return os.path.isfile(nbpath) |
|
155 | 155 | |
|
156 | # TODO: Remove this after we create the contents web service and directories are | |
|
157 | # no longer listed by the notebook web service. | |
|
156 | 158 | def list_dirs(self, path): |
|
157 | 159 | """List the directories for a given API style path.""" |
|
158 | 160 | path = path.strip('/') |
@@ -167,6 +169,8 b' class FileNotebookManager(NotebookManager):' | |||
|
167 | 169 | dirs = sorted(dirs, key=lambda item: item['name']) |
|
168 | 170 | return dirs |
|
169 | 171 | |
|
172 | # TODO: Remove this after we create the contents web service and directories are | |
|
173 | # no longer listed by the notebook web service. | |
|
170 | 174 | def get_dir_model(self, name, path=''): |
|
171 | 175 | """Get the directory model given a directory name and its API style path""" |
|
172 | 176 | path = path.strip('/') |
@@ -15,6 +15,7 b' from IPython.html.utils import url_path_join' | |||
|
15 | 15 | from ..filenbmanager import FileNotebookManager |
|
16 | 16 | from ..nbmanager import NotebookManager |
|
17 | 17 | |
|
18 | ||
|
18 | 19 | class TestFileNotebookManager(TestCase): |
|
19 | 20 | |
|
20 | 21 | def test_nb_dir(self): |
@@ -21,6 +21,12 b' from IPython.utils import py3compat' | |||
|
21 | 21 | from IPython.utils.data import uniq_stable |
|
22 | 22 | |
|
23 | 23 | |
|
24 | # TODO: Remove this after we create the contents web service and directories are | |
|
25 | # no longer listed by the notebook web service. | |
|
26 | def notebooks_only(nb_list): | |
|
27 | return [nb for nb in nb_list if 'type' not in nb] | |
|
28 | ||
|
29 | ||
|
24 | 30 | class NBAPI(object): |
|
25 | 31 | """Wrapper for notebook API calls.""" |
|
26 | 32 | def __init__(self, base_url): |
@@ -125,25 +131,25 b' class APITest(NotebookTestBase):' | |||
|
125 | 131 | os.unlink(pjoin(nbdir, 'inroot.ipynb')) |
|
126 | 132 | |
|
127 | 133 | def test_list_notebooks(self): |
|
128 | nbs = self.nb_api.list().json() | |
|
134 | nbs = notebooks_only(self.nb_api.list().json()) | |
|
129 | 135 | self.assertEqual(len(nbs), 1) |
|
130 | 136 | self.assertEqual(nbs[0]['name'], 'inroot.ipynb') |
|
131 | 137 | |
|
132 | nbs = self.nb_api.list('/Directory with spaces in/').json() | |
|
138 | nbs = notebooks_only(self.nb_api.list('/Directory with spaces in/').json()) | |
|
133 | 139 | self.assertEqual(len(nbs), 1) |
|
134 | 140 | self.assertEqual(nbs[0]['name'], 'inspace.ipynb') |
|
135 | 141 | |
|
136 | nbs = self.nb_api.list(u'/unicodé/').json() | |
|
142 | nbs = notebooks_only(self.nb_api.list(u'/unicodé/').json()) | |
|
137 | 143 | self.assertEqual(len(nbs), 1) |
|
138 | 144 | self.assertEqual(nbs[0]['name'], 'innonascii.ipynb') |
|
139 | 145 | self.assertEqual(nbs[0]['path'], u'unicodé') |
|
140 | 146 | |
|
141 | nbs = self.nb_api.list('/foo/bar/').json() | |
|
147 | nbs = notebooks_only(self.nb_api.list('/foo/bar/').json()) | |
|
142 | 148 | self.assertEqual(len(nbs), 1) |
|
143 | 149 | self.assertEqual(nbs[0]['name'], 'baz.ipynb') |
|
144 | 150 | self.assertEqual(nbs[0]['path'], 'foo/bar') |
|
145 | 151 | |
|
146 | nbs = self.nb_api.list('foo').json() | |
|
152 | nbs = notebooks_only(self.nb_api.list('foo').json()) | |
|
147 | 153 | self.assertEqual(len(nbs), 4) |
|
148 | 154 | nbnames = { normalize('NFC', n['name']) for n in nbs } |
|
149 | 155 | expected = [ u'a.ipynb', u'b.ipynb', u'name with spaces.ipynb', u'unicodé.ipynb'] |
@@ -231,7 +237,7 b' class APITest(NotebookTestBase):' | |||
|
231 | 237 | self.assertEqual(resp.status_code, 204) |
|
232 | 238 | |
|
233 | 239 | for d in self.dirs + ['/']: |
|
234 | nbs = self.nb_api.list(d).json() | |
|
240 | nbs = notebooks_only(self.nb_api.list(d).json()) | |
|
235 | 241 | self.assertEqual(len(nbs), 0) |
|
236 | 242 | |
|
237 | 243 | def test_rename(self): |
@@ -240,7 +246,7 b' class APITest(NotebookTestBase):' | |||
|
240 | 246 | self.assertEqual(resp.json()['name'], 'z.ipynb') |
|
241 | 247 | assert os.path.isfile(pjoin(self.notebook_dir.name, 'foo', 'z.ipynb')) |
|
242 | 248 | |
|
243 | nbs = self.nb_api.list('foo').json() | |
|
249 | nbs = notebooks_only(self.nb_api.list('foo').json()) | |
|
244 | 250 | nbnames = set(n['name'] for n in nbs) |
|
245 | 251 | self.assertIn('z.ipynb', nbnames) |
|
246 | 252 | self.assertNotIn('a.ipynb', nbnames) |
General Comments 0
You need to be logged in to leave comments.
Login now