-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update paging implementation to handle unconventional pagination #750
Changes from all commits
1141010
058b55e
d226f36
01adad1
0f3e63d
48253d3
86e2c43
959e1a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,19 +66,38 @@ def test_method_client_output_empty(): | |
|
||
def test_method_client_output_paged(): | ||
paged = make_field(name='foos', message=make_message('Foo'), repeated=True) | ||
parent = make_field(name='parent', type=9) # str | ||
page_size = make_field(name='page_size', type=5) # int | ||
page_token = make_field(name='page_token', type=9) # str | ||
|
||
input_msg = make_message(name='ListFoosRequest', fields=( | ||
make_field(name='parent', type=9), # str | ||
make_field(name='page_size', type=5), # int | ||
make_field(name='page_token', type=9), # str | ||
parent, | ||
page_size, | ||
page_token, | ||
)) | ||
output_msg = make_message(name='ListFoosResponse', fields=( | ||
paged, | ||
make_field(name='next_page_token', type=9), # str | ||
)) | ||
method = make_method('ListFoos', | ||
input_message=input_msg, | ||
output_message=output_msg, | ||
) | ||
method = make_method( | ||
'ListFoos', | ||
input_message=input_msg, | ||
output_message=output_msg, | ||
) | ||
assert method.paged_result_field == paged | ||
assert method.client_output.ident.name == 'ListFoosPager' | ||
|
||
max_results = make_field(name='max_results', type=5) # int | ||
input_msg = make_message(name='ListFoosRequest', fields=( | ||
parent, | ||
max_results, | ||
page_token, | ||
)) | ||
method = make_method( | ||
'ListFoos', | ||
input_message=input_msg, | ||
output_message=output_msg, | ||
) | ||
assert method.paged_result_field == paged | ||
assert method.client_output.ident.name == 'ListFoosPager' | ||
|
||
|
@@ -123,6 +142,19 @@ def test_method_paged_result_field_no_page_field(): | |
) | ||
assert method.paged_result_field is None | ||
|
||
method = make_method( | ||
name='Foo', | ||
input_message=make_message( | ||
name='FooRequest', | ||
fields=(make_field(name='page_token', type=9),) # str | ||
), | ||
output_message=make_message( | ||
name='FooResponse', | ||
fields=(make_field(name='next_page_token', type=9),) # str | ||
) | ||
) | ||
assert method.paged_result_field is None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we add tests in this file for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mapped responses are treated the same here. Checking for repeated fields should be sufficient since mapped fields are also repeated. Test for |
||
|
||
|
||
def test_method_paged_result_ref_types(): | ||
input_msg = make_message( | ||
|
@@ -139,7 +171,7 @@ def test_method_paged_result_ref_types(): | |
name='ListMolluscsResponse', | ||
fields=( | ||
make_field(name='molluscs', message=mollusc_msg, repeated=True), | ||
make_field(name='next_page_token', type=9) | ||
make_field(name='next_page_token', type=9) # str | ||
), | ||
module='mollusc' | ||
) | ||
|
@@ -207,7 +239,7 @@ def test_flattened_ref_types(): | |
|
||
|
||
def test_method_paged_result_primitive(): | ||
paged = make_field(name='squids', type=9, repeated=True) | ||
paged = make_field(name='squids', type=9, repeated=True) # str | ||
input_msg = make_message( | ||
name='ListSquidsRequest', | ||
fields=( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the results of this template visible in a generated file within this repo? (just asking, the repo may not be structured that way)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. It may be useful to include a generated client but that might clog the repo. The showcase client is generated as part of CircleCI tests though.