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