Merge "Changes in the new marker, initialise new marker to aviod bug."

This commit is contained in:
Jenkins 2015-08-06 17:25:37 +00:00 committed by Gerrit Code Review
commit a28f8e22fd
2 changed files with 17 additions and 0 deletions

View File

@ -856,6 +856,7 @@ class Resource(collections.MutableMapping):
# less than our limit, we don't need to do an extra request
# to get back an empty data set, which acts as a sentinel.
yielded = 0
new_marker = None
for data in resp:
value = cls.existing(**data)
new_marker = value.id

View File

@ -814,6 +814,22 @@ class ResourceTests(base.TestTransportBase):
self.assertEqual(session.get.call_count, len(pages))
self.assertEqual(len(full_page + full_page + last_page), len(results))
def test_empty_list(self):
page = []
session = mock.Mock()
session.get = mock.Mock()
full_response = mock.Mock()
full_response.body = {FakeResource.resources_key: page}
pages = [full_response]
session.get.side_effect = pages
results = list(FakeResource.list(session, path_args=fake_arguments,
paginated=True))
self.assertEqual(session.get.call_count, len(pages))
self.assertEqual(len(page), len(results))
def test_attrs_name(self):
obj = FakeResource()