

def testListCommonPrefixes(self):
    files = ['onefile', 'onedir/foo', 'twodir/foo', 'twodir/bar', 'twodir/bardir/baz', 'twodir2/foo']
    for f in files:
        self._RunAsync(self.object_store.Put, f, 'test')
    (prefixes, keys) = self._RunAsync(self.object_store.ListCommonPrefixes, '/')
    self.assertEqual(prefixes, ['onedir/', 'test/', 'twodir/', 'twodir2/'])
    self.assertEqual(keys, ['onefile'])
    (prefixes, keys) = self._RunAsync(self.object_store.ListCommonPrefixes, '/', prefix='two')
    self.assertEqual(prefixes, ['twodir/', 'twodir2/'])
    self.assertEqual(keys, [])
    (prefixes, keys) = self._RunAsync(self.object_store.ListCommonPrefixes, '/', prefix='two', maxkeys=1)
    self.assertEqual(prefixes, ['twodir/'])
    self.assertEqual(keys, [])
    (prefixes, keys) = self._RunAsync(self.object_store.ListCommonPrefixes, '/', prefix='twodir/')
    self.assertEqual(prefixes, ['twodir/bardir/'])
    self.assertEqual(keys, ['twodir/bar', 'twodir/foo'])
    (prefixes, keys) = self._RunAsync(self.object_store.ListCommonPrefixes, '/', prefix='twodir/', maxkeys=1)
    self.assertEqual(prefixes, [])
    self.assertEqual(keys, ['twodir/bar'])
    for f in files:
        self._RunAsync(self.object_store.Delete, f)

dataset/ETHPy150Open viewfinderco/viewfinder/backend/storage/test/s3_object_store_test.py S3ObjectStoreTestCase.testListCommonPrefixes/original