Show More
@@ -182,7 +182,8 b' class FileNotebookManager(NotebookManager):' | |||||
182 | dirs = [] |
|
182 | dirs = [] | |
183 | for name in dir_names: |
|
183 | for name in dir_names: | |
184 | os_path = self._get_os_path(name, path) |
|
184 | os_path = self._get_os_path(name, path) | |
185 |
if os.path.isdir(os_path) and not is_hidden(os_path, self.notebook_dir) |
|
185 | if os.path.isdir(os_path) and not is_hidden(os_path, self.notebook_dir)\ | |
|
186 | and not name.startswith('_'): | |||
186 | try: |
|
187 | try: | |
187 | model = self.get_dir_model(name, path) |
|
188 | model = self.get_dir_model(name, path) | |
188 | except IOError: |
|
189 | except IOError: |
@@ -26,6 +26,9 b' from IPython.utils.data import uniq_stable' | |||||
26 | def notebooks_only(nb_list): |
|
26 | def notebooks_only(nb_list): | |
27 | return [nb for nb in nb_list if nb['type']=='notebook'] |
|
27 | return [nb for nb in nb_list if nb['type']=='notebook'] | |
28 |
|
28 | |||
|
29 | def dirs_only(nb_list): | |||
|
30 | return [x for x in nb_list if x['type']=='directory'] | |||
|
31 | ||||
29 |
|
32 | |||
30 | class NBAPI(object): |
|
33 | class NBAPI(object): | |
31 | """Wrapper for notebook API calls.""" |
|
34 | """Wrapper for notebook API calls.""" | |
@@ -100,14 +103,16 b' class APITest(NotebookTestBase):' | |||||
100 | ('foo/bar', 'baz'), |
|
103 | ('foo/bar', 'baz'), | |
101 | (u'å b', u'ç d') |
|
104 | (u'å b', u'ç d') | |
102 | ] |
|
105 | ] | |
|
106 | hidden_dirs = ['.hidden', '__pycache__'] | |||
103 |
|
107 | |||
104 | dirs = uniq_stable([d for (d,n) in dirs_nbs]) |
|
108 | dirs = uniq_stable([d for (d,n) in dirs_nbs]) | |
105 | del dirs[0] # remove '' |
|
109 | del dirs[0] # remove '' | |
|
110 | top_level_dirs = {d.split('/')[0] for d in dirs} | |||
106 |
|
111 | |||
107 | def setUp(self): |
|
112 | def setUp(self): | |
108 | nbdir = self.notebook_dir.name |
|
113 | nbdir = self.notebook_dir.name | |
109 |
|
114 | |||
110 | for d in self.dirs: |
|
115 | for d in (self.dirs + self.hidden_dirs): | |
111 | d.replace('/', os.sep) |
|
116 | d.replace('/', os.sep) | |
112 | if not os.path.isdir(pjoin(nbdir, d)): |
|
117 | if not os.path.isdir(pjoin(nbdir, d)): | |
113 | os.mkdir(pjoin(nbdir, d)) |
|
118 | os.mkdir(pjoin(nbdir, d)) | |
@@ -124,7 +129,7 b' class APITest(NotebookTestBase):' | |||||
124 | def tearDown(self): |
|
129 | def tearDown(self): | |
125 | nbdir = self.notebook_dir.name |
|
130 | nbdir = self.notebook_dir.name | |
126 |
|
131 | |||
127 | for dname in ['foo', 'Directory with spaces in', u'unicodé', u'å b']: |
|
132 | for dname in (list(self.top_level_dirs) + self.hidden_dirs): | |
128 | shutil.rmtree(pjoin(nbdir, dname), ignore_errors=True) |
|
133 | shutil.rmtree(pjoin(nbdir, dname), ignore_errors=True) | |
129 |
|
134 | |||
130 | if os.path.isfile(pjoin(nbdir, 'inroot.ipynb')): |
|
135 | if os.path.isfile(pjoin(nbdir, 'inroot.ipynb')): | |
@@ -156,6 +161,11 b' class APITest(NotebookTestBase):' | |||||
156 | expected = { normalize('NFC', name) for name in expected } |
|
161 | expected = { normalize('NFC', name) for name in expected } | |
157 | self.assertEqual(nbnames, expected) |
|
162 | self.assertEqual(nbnames, expected) | |
158 |
|
163 | |||
|
164 | def test_list_dirs(self): | |||
|
165 | dirs = dirs_only(self.nb_api.list().json()) | |||
|
166 | dir_names = {d['name'] for d in dirs} | |||
|
167 | self.assertEqual(dir_names, self.top_level_dirs) # Excluding hidden dirs | |||
|
168 | ||||
159 | def test_list_nonexistant_dir(self): |
|
169 | def test_list_nonexistant_dir(self): | |
160 | with assert_http_error(404): |
|
170 | with assert_http_error(404): | |
161 | self.nb_api.list('nonexistant') |
|
171 | self.nb_api.list('nonexistant') |
General Comments 0
You need to be logged in to leave comments.
Login now