Show More
@@ -188,8 +188,30 b' class TestContentsManager(TestCase):' | |||||
188 | self.assertEqual(model2['path'], '{0}/{1}'.format(sub_dir.strip('/'), name)) |
|
188 | self.assertEqual(model2['path'], '{0}/{1}'.format(sub_dir.strip('/'), name)) | |
189 |
|
189 | |||
190 | # Test getting directory model |
|
190 | # Test getting directory model | |
|
191 | ||||
|
192 | # Create a sub-sub directory to test getting directory contents with a | |||
|
193 | # subdir. | |||
|
194 | sub_sub_dir_path = 'foo/bar' | |||
|
195 | self.make_dir(sub_sub_dir_path) | |||
|
196 | ||||
191 | dirmodel = cm.get('foo') |
|
197 | dirmodel = cm.get('foo') | |
192 | self.assertEqual(dirmodel['type'], 'directory') |
|
198 | self.assertEqual(dirmodel['type'], 'directory') | |
|
199 | self.assertIsInstance(dirmodel['content'], list) | |||
|
200 | self.assertEqual(len(dirmodel['content']), 2) | |||
|
201 | ||||
|
202 | # Directory contents should match the contents of each individual entry | |||
|
203 | # when requested with content=False. | |||
|
204 | model2_no_content = cm.get(sub_dir + name, content=False) | |||
|
205 | sub_sub_dir_no_content = cm.get(sub_sub_dir_path, content=False) | |||
|
206 | for entry in dirmodel['content']: | |||
|
207 | # Order isn't guaranteed by the spec, so this is a hacky way of | |||
|
208 | # verifying that all entries are matched. | |||
|
209 | if entry['path'] == sub_sub_dir_no_content['path']: | |||
|
210 | self.assertEqual(entry, sub_sub_dir_no_content) | |||
|
211 | elif entry['path'] == model2_no_content['path']: | |||
|
212 | self.assertEqual(entry, model2_no_content) | |||
|
213 | else: | |||
|
214 | self.fail("Unexpected directory entry: %s" % entry()) | |||
193 |
|
215 | |||
194 | with self.assertRaises(HTTPError): |
|
216 | with self.assertRaises(HTTPError): | |
195 | cm.get('foo', type='file') |
|
217 | cm.get('foo', type='file') |
General Comments 0
You need to be logged in to leave comments.
Login now