Skip to content

Commit 1493107

Browse files
authored
chore: sort query params in rest unit tests (googleapis#1155)
I've confirmed that the unit tests in python-compute are still passing with this change. Fixes googleapis#1154
1 parent c1b2310 commit 1493107

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

gapic/ads-templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,15 +1015,15 @@ def test_{{ method_name }}_rest_required_fields(request_type={{ method.input.ide
10151015
{% set mock_value = req_field.primitive_mock_as_str() %}
10161016
{% if method.query_params %}
10171017
# Check that path parameters and body parameters are not mixing in.
1018-
assert not set(unset_fields) - set(({% for param in method.query_params %}"{{param|camel_case }}", {% endfor %}))
1018+
assert not set(unset_fields) - set(({% for param in method.query_params|sort %}"{{param|camel_case }}", {% endfor %}))
10191019
{% endif %}
10201020
jsonified_request["{{ field_name }}"] = {{ mock_value }}
10211021
{% endfor %}
10221022

10231023
unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).{{ method.name | snake_case }}._get_unset_required_fields(jsonified_request)
10241024
{% if method.query_params %}
10251025
# Check that path parameters and body parameters are not mixing in.
1026-
assert not set(unset_fields) - set(({% for param in method.query_params %}"{{param}}",
1026+
assert not set(unset_fields) - set(({% for param in method.query_params|sort %}"{{param}}",
10271027
{% endfor %}))
10281028
{% endif %}
10291029
jsonified_request.update(unset_fields)
@@ -1109,7 +1109,7 @@ def test_{{ method_name }}_rest_unset_required_fields():
11091109
transport = transports.{{ service.rest_transport_name }}(credentials=ga_credentials.AnonymousCredentials)
11101110

11111111
unset_fields = transport.{{ method.name|snake_case }}._get_unset_required_fields({})
1112-
assert set(unset_fields) == (set(({% for param in method.query_params %}"{{ param|camel_case }}", {% endfor %})) & set(({% for param in method.input.required_fields %}"{{param.name|camel_case}}", {% endfor %})))
1112+
assert set(unset_fields) == (set(({% for param in method.query_params|sort %}"{{ param|camel_case }}", {% endfor %})) & set(({% for param in method.input.required_fields %}"{{param.name|camel_case}}", {% endfor %})))
11131113

11141114

11151115
{% endif %}{# required_fields #}

gapic/templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ def test_{{ method_name }}_rest_required_fields(request_type={{ method.input.ide
14261426
unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).{{ method.name | snake_case }}._get_unset_required_fields(jsonified_request)
14271427
{% if method.query_params %}
14281428
# Check that path parameters and body parameters are not mixing in.
1429-
assert not set(unset_fields) - set(({% for param in method.query_params %}"{{param}}", {% endfor %}))
1429+
assert not set(unset_fields) - set(({% for param in method.query_params|sort %}"{{param}}", {% endfor %}))
14301430
{% endif %}
14311431
jsonified_request.update(unset_fields)
14321432

@@ -1511,7 +1511,7 @@ def test_{{ method_name }}_rest_unset_required_fields():
15111511
transport = transports.{{ service.rest_transport_name }}(credentials=ga_credentials.AnonymousCredentials)
15121512

15131513
unset_fields = transport.{{ method.name|snake_case }}._get_unset_required_fields({})
1514-
assert set(unset_fields) == (set(({% for param in method.query_params %}"{{ param|camel_case }}", {% endfor %})) & set(({% for param in method.input.required_fields %}"{{ param.name|camel_case }}", {% endfor %})))
1514+
assert set(unset_fields) == (set(({% for param in method.query_params|sort %}"{{ param|camel_case }}", {% endfor %})) & set(({% for param in method.input.required_fields %}"{{ param.name|camel_case }}", {% endfor %})))
15151515

15161516
{% endif %}{# required_fields #}
15171517

0 commit comments

Comments
 (0)