Show More
@@ -182,7 +182,8 b' class FileNotebookManager(NotebookManager):' | |||
|
182 | 182 | dirs = [] |
|
183 | 183 | for name in dir_names: |
|
184 | 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 | 187 | try: |
|
187 | 188 | model = self.get_dir_model(name, path) |
|
188 | 189 | except IOError: |
@@ -26,6 +26,9 b' from IPython.utils.data import uniq_stable' | |||
|
26 | 26 | def notebooks_only(nb_list): |
|
27 | 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 | 33 | class NBAPI(object): |
|
31 | 34 | """Wrapper for notebook API calls.""" |
@@ -100,14 +103,16 b' class APITest(NotebookTestBase):' | |||
|
100 | 103 | ('foo/bar', 'baz'), |
|
101 | 104 | (u'å b', u'ç d') |
|
102 | 105 | ] |
|
106 | hidden_dirs = ['.hidden', '__pycache__'] | |
|
103 | 107 | |
|
104 | 108 | dirs = uniq_stable([d for (d,n) in dirs_nbs]) |
|
105 | 109 | del dirs[0] # remove '' |
|
110 | top_level_dirs = {d.split('/')[0] for d in dirs} | |
|
106 | 111 | |
|
107 | 112 | def setUp(self): |
|
108 | 113 | nbdir = self.notebook_dir.name |
|
109 | 114 | |
|
110 | for d in self.dirs: | |
|
115 | for d in (self.dirs + self.hidden_dirs): | |
|
111 | 116 | d.replace('/', os.sep) |
|
112 | 117 | if not os.path.isdir(pjoin(nbdir, d)): |
|
113 | 118 | os.mkdir(pjoin(nbdir, d)) |
@@ -124,7 +129,7 b' class APITest(NotebookTestBase):' | |||
|
124 | 129 | def tearDown(self): |
|
125 | 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 | 133 | shutil.rmtree(pjoin(nbdir, dname), ignore_errors=True) |
|
129 | 134 | |
|
130 | 135 | if os.path.isfile(pjoin(nbdir, 'inroot.ipynb')): |
@@ -156,6 +161,11 b' class APITest(NotebookTestBase):' | |||
|
156 | 161 | expected = { normalize('NFC', name) for name in expected } |
|
157 | 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 | 169 | def test_list_nonexistant_dir(self): |
|
160 | 170 | with assert_http_error(404): |
|
161 | 171 | self.nb_api.list('nonexistant') |
General Comments 0
You need to be logged in to leave comments.
Login now