Skip to content

Commit

Permalink
fix: set default argument of jinja-filters.map() when looking up …
Browse files Browse the repository at this point in the history
…attributes (#1989)
  • Loading branch information
parthea committed Apr 12, 2024
1 parent b62da87 commit 3e74a0a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class {{ message.name }}({{ p }}.Message):
{% endif %}
{% endif %}
{# Use select filter to capture nested values. See https://github.com/googleapis/gapic-generator-python/issues/1083 #}
{%- if message.fields.values() | map(attribute="oneof") | select | list %}
{%- if message.fields.values() | map(attribute="oneof", default="") | select | list %}
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

{% endif %}
Expand Down Expand Up @@ -43,7 +43,7 @@ class {{ message.name }}({{ p }}.Message):
{% endif %}
{% endfor %}

{% if "next_page_token" in message.fields.values()|map(attribute='name') %}
{% if "next_page_token" in message.fields.values()|map(attribute='name', default="") %}
@property
def raw_page(self):
return self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def test_{{ method_name }}(request_type, transport: str = 'grpc'):
for message in response:
assert isinstance(message, {{ method.output.ident }})
{% else %}
{% if "next_page_token" in method.output.fields.values()|map(attribute='name') and not method.paged_result_field %}
{% if "next_page_token" in method.output.fields.values()|map(attribute='name', default="") and not method.paged_result_field %}
{# Cheeser assertion to force code coverage for bad paginated methods #}
assert response.raw_page is response
{% endif %}
Expand Down Expand Up @@ -1215,7 +1215,7 @@ def test_{{ method.name|snake_case }}_rest(request_type):
response = client.{{ method_name }}(request)
{% endif %}

{% if "next_page_token" in method.output.fields.values()|map(attribute='name') and not method.paged_result_field %}
{% if "next_page_token" in method.output.fields.values()|map(attribute='name', default="") and not method.paged_result_field %}
{# Cheeser assertion to force code coverage for bad paginated methods #}
assert response.raw_page is response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class {{ message.name }}({{ p }}.Message):
{% endif %}
{% endif %}
{# Use select filter to capture nested values. See https://github.com/googleapis/gapic-generator-python/issues/1083 #}
{%- if message.fields.values() | map(attribute="oneof") | select | list %}
{%- if message.fields.values() | map(attribute="oneof", default="") | select | list %}
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

{% endif %}
Expand Down Expand Up @@ -43,7 +43,7 @@ class {{ message.name }}({{ p }}.Message):
{% endif %}
{% endfor %}

{% if "next_page_token" in message.fields.values()|map(attribute='name') %}
{% if "next_page_token" in message.fields.values()|map(attribute='name', default="") %}
@property
def raw_page(self):
return self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_{{ method_name }}(request_type, transport: str = 'grpc'):
for message in response:
assert isinstance(message, {{ method.output.ident }})
{% else %}
{% if "next_page_token" in method.output.fields.values()|map(attribute='name') and not method.paged_result_field %}
{% if "next_page_token" in method.output.fields.values()|map(attribute='name', default="") and not method.paged_result_field %}
{# Cheeser assertion to force code coverage for bad paginated methods #}
assert response.raw_page is response
{% endif %}
Expand Down Expand Up @@ -1278,7 +1278,7 @@ def test_{{ method_name }}_rest(request_type):
response = client.{{ method_name }}(request)
{% endif %}

{% if "next_page_token" in method_output.fields.values()|map(attribute='name') and not method.paged_result_field %}
{% if "next_page_token" in method_output.fields.values()|map(attribute='name', default="") and not method.paged_result_field %}
{# Cheeser assertion to force code coverage for bad paginated methods #}
assert response.raw_page is response

Expand Down

0 comments on commit 3e74a0a

Please sign in to comment.