Merge "Make container list --all work"

This commit is contained in:
Zuul 2020-06-09 00:21:52 +00:00 committed by Gerrit Code Review
commit 831dd3fe12
2 changed files with 36 additions and 36 deletions

View File

@ -87,7 +87,7 @@ class APIv1(api.BaseAPI):
def container_list(
self,
all_data=False,
full_listing=False,
limit=None,
marker=None,
end_marker=None,
@ -96,7 +96,7 @@ class APIv1(api.BaseAPI):
):
"""Get containers in an account
:param boolean all_data:
:param boolean full_listing:
if True, return a full listing, else returns a max of
10000 listings
:param integer limit:
@ -113,7 +113,7 @@ class APIv1(api.BaseAPI):
params['format'] = 'json'
if all_data:
if full_listing:
data = listing = self.container_list(
limit=limit,
marker=marker,
@ -299,7 +299,7 @@ class APIv1(api.BaseAPI):
def object_list(
self,
container=None,
all_data=False,
full_listing=False,
limit=None,
marker=None,
end_marker=None,
@ -311,7 +311,7 @@ class APIv1(api.BaseAPI):
:param string container:
container name to get a listing for
:param boolean all_data:
:param boolean full_listing:
if True, return a full listing, else returns a max of
10000 listings
:param integer limit:
@ -332,7 +332,7 @@ class APIv1(api.BaseAPI):
return None
params['format'] = 'json'
if all_data:
if full_listing:
data = listing = self.object_list(
container=container,
limit=limit,

View File

@ -30,8 +30,10 @@ FAKE_CONTAINER = 'rainbarrel'
FAKE_OBJECT = 'spigot'
LIST_CONTAINER_RESP = [
'qaz',
'fred',
{"name": "qaz", "count": 0, "bytes": 0,
"last_modified": "2020-05-16T05:52:07.377550"},
{"name": "fred", "count": 0, "bytes": 0,
"last_modified": "2020-05-16T05:55:07.377550"},
]
LIST_OBJECT_RESP = [
@ -117,34 +119,32 @@ class TestContainer(TestObjectAPIv1):
)
self.assertEqual(LIST_CONTAINER_RESP, ret)
# def test_container_list_full_listing(self):
# sess = self.app.client_manager.session
#
# def side_effect(*args, **kwargs):
# rv = sess.get().json.return_value
# sess.get().json.return_value = []
# sess.get().json.side_effect = None
# return rv
#
# resp = [{'name': 'is-name'}]
# sess.get().json.return_value = resp
# sess.get().json.side_effect = side_effect
#
# data = lib_container.list_containers(
# self.app.client_manager.session,
# fake_url,
# full_listing=True,
# )
#
# # Check expected values
# sess.get.assert_called_with(
# fake_url,
# params={
# 'format': 'json',
# 'marker': 'is-name',
# }
# )
# self.assertEqual(resp, data)
def test_container_list_full_listing(self):
self.requests_mock.register_uri(
'GET',
FAKE_URL + '?limit=1&format=json',
json=[LIST_CONTAINER_RESP[0]],
status_code=200,
)
self.requests_mock.register_uri(
'GET',
FAKE_URL +
'?marker=%s&limit=1&format=json' % LIST_CONTAINER_RESP[0]['name'],
json=[LIST_CONTAINER_RESP[1]],
status_code=200,
)
self.requests_mock.register_uri(
'GET',
FAKE_URL +
'?marker=%s&limit=1&format=json' % LIST_CONTAINER_RESP[1]['name'],
json=[],
status_code=200,
)
ret = self.api.container_list(
limit=1,
full_listing=True,
)
self.assertEqual(LIST_CONTAINER_RESP, ret)
def test_container_show(self):
headers = {