Skip to content

Commit

Permalink
Merge pull request #485 from kyleknap/build-full-result-clients
Browse files Browse the repository at this point in the history
Fix build_full_result for clients
  • Loading branch information
kyleknap committed Mar 10, 2015
2 parents d2792df + 7867b40 commit 2eee0f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion botocore/paginate.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,15 @@ def build_full_result(self):
for result_expression in self.result_keys:
set_value_from_jmespath(complete_result,
result_expression.expression, [])
for _, page in self:
for response in self:
page = response
# We want to try to catch operation object pagination
# and format correctly for those. They come in the form
# of a tuple of two elements: (http_response, parsed_responsed).
# We want the parsed_response as that is what the page iterator
# uses. We can remove it though once operation objects are removed.
if isinstance(response, tuple) and len(response) == 2:
page = response[1]
# We're incrementally building the full response page
# by page. For each page in the response we need to
# inject the necessary components from the page
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_paginate.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ def test_with_page_size(self):
mock.call(Marker='m2', MaxKeys=1)]
)

def test_build_full_result_with_single_key(self):
responses = [
{"Users": ["User1"], "Marker": "m1"},
{"Users": ["User2"], "Marker": "m2"},
{"Users": ["User3"]}
]
self.method.side_effect = responses
pages = self.paginator.paginate()
complete = pages.build_full_result()
self.assertEqual(complete, {'Users': ['User1', 'User2', 'User3']})


class TestPaginatorObjectConstruction(unittest.TestCase):
def test_pagination_delegates_to_paginator(self):
Expand Down

0 comments on commit 2eee0f1

Please sign in to comment.