Commit 338d665d authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Merge branch 'feature-store' into develop

parents 047b40d2 3f7e4e14
......@@ -280,16 +280,47 @@ class StorageClient(Client):
if r.status_code == 404:
raise ClientError("Object %s not found" % obj, r.status_code)
def list_objects(self):
def list_objects(
:param limit: (integer) The amount of results requested
:param marker: (string) Return containers with name lexicographically
after marker
:param prefix: (string) Return objects starting with prefix
:param format: (string) reply format can be json or xml (default:json)
:param delimiter: (string) Return objects up to the delimiter
:param path: (string) assume prefix = path and delimiter = /
(overwrites prefix and delimiter)
:returns: (dict)
:raises ClientError: 404 Invalid account
path = path4url(self.account, self.container)
self.set_param('format', 'json')
r = self.get(path, success=(200, 204, 304, 404), )
restpath = path4url(self.account, self.container)
self.set_param('format', format or 'json')
self.set_param('limit', limit, iff=limit)
self.set_param('marker', marker, iff=marker)
if path:
self.set_param('path', path)
self.set_param('prefix', prefix, iff=prefix)
self.set_param('delimiter', delimiter, iff=delimiter)
r = self.get(restpath, success=(200, 204, 304, 404), )
if r.status_code == 404:
raise ClientError(
"Invalid account (%s) for that container" % self.account,
......@@ -386,7 +386,27 @@ class StorageClient(TestCase):
self.assert_dicts_are_equal(r[i], object_list[i])
exp = '/%s/%s' % (acc, cont)
get.assert_called_once_with(exp, success=(200, 204, 304, 404))
SP.assert_called_once_with('format', 'json')
self.assertEqual(SP.mock_calls, [
call('format', 'json'),
call('limit', None, iff=None),
call('marker', None, iff=None),
call('prefix', None, iff=None),
call('delimiter', None, iff=None)])
format='xml', limit=10, marker='X', path='/lala')
self.assertEqual(SP.mock_calls[-4:], [
call('format', 'xml'),
call('limit', 10, iff=10),
call('marker', 'X', iff='X'),
call('path', '/lala')])
self.client.list_objects(delimiter='X', prefix='/lala')
self.assertEqual(SP.mock_calls[-5:], [
call('format', 'json'),
call('limit', None, iff=None),
call('marker', None, iff=None),
call('prefix', '/lala', iff='/lala'),
call('delimiter', 'X', iff='X'),
FR.status_code = 304
self.assertEqual(self.client.list_objects(), [])
FR.status_code = 404
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment