Show More
@@ -227,22 +227,40 b' class TestContentsManager(TestCase):' | |||
|
227 | 227 | self.assertEqual(model2['name'], 'Untitled.ipynb') |
|
228 | 228 | self.assertEqual(model2['path'], '{0}/{1}'.format(sub_dir.strip('/'), name)) |
|
229 | 229 | |
|
230 | # Test with a regular file. | |
|
231 | file_model_path = cm.new_untitled(path=sub_dir, ext='.txt')['path'] | |
|
232 | file_model = cm.get(file_model_path) | |
|
233 | self.assertDictContainsSubset( | |
|
234 | { | |
|
235 | 'content': u'', | |
|
236 | 'format': 'text', | |
|
237 | 'mimetype': u'text/plain', | |
|
238 | 'name': u'untitled.txt', | |
|
239 | 'path': u'foo/untitled.txt', | |
|
240 | 'type': u'file', | |
|
241 | 'writable': True, | |
|
242 | }, | |
|
243 | file_model, | |
|
244 | ) | |
|
245 | self.assertIn('created', file_model) | |
|
246 | self.assertIn('last_modified', file_model) | |
|
247 | ||
|
230 | 248 | # Test getting directory model |
|
231 | 249 | |
|
232 | 250 | # Create a sub-sub directory to test getting directory contents with a |
|
233 | 251 | # subdir. |
|
234 | 252 | self.make_dir('foo/bar') |
|
235 | ||
|
236 | 253 | dirmodel = cm.get('foo') |
|
237 | 254 | self.assertEqual(dirmodel['type'], 'directory') |
|
238 | 255 | self.assertIsInstance(dirmodel['content'], list) |
|
239 |
self.assertEqual(len(dirmodel['content']), |
|
|
256 | self.assertEqual(len(dirmodel['content']), 3) | |
|
240 | 257 | self.assertEqual(dirmodel['path'], 'foo') |
|
241 | 258 | self.assertEqual(dirmodel['name'], 'foo') |
|
242 | 259 | |
|
243 | 260 | # Directory contents should match the contents of each individual entry |
|
244 | 261 | # when requested with content=False. |
|
245 | 262 | model2_no_content = cm.get(sub_dir + name, content=False) |
|
263 | file_model_no_content = cm.get(u'foo/untitled.txt', content=False) | |
|
246 | 264 | sub_sub_dir_no_content = cm.get('foo/bar', content=False) |
|
247 | 265 | self.assertEqual(sub_sub_dir_no_content['path'], 'foo/bar') |
|
248 | 266 | self.assertEqual(sub_sub_dir_no_content['name'], 'bar') |
@@ -254,6 +272,8 b' class TestContentsManager(TestCase):' | |||
|
254 | 272 | self.assertEqual(entry, sub_sub_dir_no_content) |
|
255 | 273 | elif entry['path'] == model2_no_content['path']: |
|
256 | 274 | self.assertEqual(entry, model2_no_content) |
|
275 | elif entry['path'] == file_model_no_content['path']: | |
|
276 | self.assertEqual(entry, file_model_no_content) | |
|
257 | 277 | else: |
|
258 | 278 | self.fail("Unexpected directory entry: %s" % entry()) |
|
259 | 279 |
General Comments 0
You need to be logged in to leave comments.
Login now