Skip to content

Commit

Permalink
fix: primitive repeated fields are now correctly auto paginated (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
software-dov authored Jul 10, 2020
1 parent a8be788 commit 61a2cc0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gapic/schema/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def paged_result_field(self) -> Optional[Field]:

# Return the first repeated field.
for field in self.output.fields.values():
if field.repeated and field.message:
if field.repeated:
return field

# We found no repeated fields. Return None.
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/schema/wrappers/test_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,29 @@ def test_flattened_ref_types():
assert expected_flat_ref_type_names == actual_flat_ref_type_names


def test_method_paged_result_primitive():
paged = make_field(name='squids', type=9, repeated=True)
input_msg = make_message(
name='ListSquidsRequest',
fields=(
make_field(name='parent', type=9), # str
make_field(name='page_size', type=5), # int
make_field(name='page_token', type=9), # str
),
)
output_msg = make_message(name='ListFoosResponse', fields=(
paged,
make_field(name='next_page_token', type=9), # str
))
method = make_method(
'ListSquids',
input_message=input_msg,
output_message=output_msg,
)
assert method.paged_result_field == paged
assert method.client_output.ident.name == 'ListSquidsPager'


def test_method_field_headers_none():
method = make_method('DoSomething')
assert isinstance(method.field_headers, collections.abc.Sequence)
Expand Down

0 comments on commit 61a2cc0

Please sign in to comment.