diff --git a/IPython/html/services/contents/tests/test_manager.py b/IPython/html/services/contents/tests/test_manager.py index 55d5e41..cae22cf 100644 --- a/IPython/html/services/contents/tests/test_manager.py +++ b/IPython/html/services/contents/tests/test_manager.py @@ -227,22 +227,40 @@ class TestContentsManager(TestCase): self.assertEqual(model2['name'], 'Untitled.ipynb') self.assertEqual(model2['path'], '{0}/{1}'.format(sub_dir.strip('/'), name)) + # Test with a regular file. + file_model_path = cm.new_untitled(path=sub_dir, ext='.txt')['path'] + file_model = cm.get(file_model_path) + self.assertDictContainsSubset( + { + 'content': u'', + 'format': 'text', + 'mimetype': u'text/plain', + 'name': u'untitled.txt', + 'path': u'foo/untitled.txt', + 'type': u'file', + 'writable': True, + }, + file_model, + ) + self.assertIn('created', file_model) + self.assertIn('last_modified', file_model) + # Test getting directory model # Create a sub-sub directory to test getting directory contents with a # subdir. self.make_dir('foo/bar') - dirmodel = cm.get('foo') self.assertEqual(dirmodel['type'], 'directory') self.assertIsInstance(dirmodel['content'], list) - self.assertEqual(len(dirmodel['content']), 2) + self.assertEqual(len(dirmodel['content']), 3) self.assertEqual(dirmodel['path'], 'foo') self.assertEqual(dirmodel['name'], 'foo') # Directory contents should match the contents of each individual entry # when requested with content=False. model2_no_content = cm.get(sub_dir + name, content=False) + file_model_no_content = cm.get(u'foo/untitled.txt', content=False) sub_sub_dir_no_content = cm.get('foo/bar', content=False) self.assertEqual(sub_sub_dir_no_content['path'], 'foo/bar') self.assertEqual(sub_sub_dir_no_content['name'], 'bar') @@ -254,6 +272,8 @@ class TestContentsManager(TestCase): self.assertEqual(entry, sub_sub_dir_no_content) elif entry['path'] == model2_no_content['path']: self.assertEqual(entry, model2_no_content) + elif entry['path'] == file_model_no_content['path']: + self.assertEqual(entry, file_model_no_content) else: self.fail("Unexpected directory entry: %s" % entry())