Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions google/api_core/path_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ def transcode(http_options, **request_kwargs):
]
path_args = {field: get_field(request_kwargs, field) for field in path_fields}
request["uri"] = expand(uri_template, **path_args)

# Remove fields used in uri path from request
leftovers = copy.deepcopy(request_kwargs)
for path_field in path_fields:
Expand All @@ -297,4 +296,8 @@ def transcode(http_options, **request_kwargs):
request["method"] = http_option["method"]
return request

raise ValueError("Request obj does not match any template")
raise ValueError(
"Request {} does not match any URL path template in available HttpRule's {}".format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Request {} does not match any URL path template in available HttpRule's {}".format(
"Request {} does not match any URL path template in available HttpRules {}".format(

request_kwargs, [opt["uri"] for opt in http_options]
)
)
2 changes: 1 addition & 1 deletion tests/unit/test_path_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def test_transcode_with_additional_bindings(
[[["get", "/v1/{name}", ""]], {"name": "first/last"}],
[[["get", "/v1/{name=mr/*/*}", ""]], {"name": "first/last"}],
[[["post", "/v1/{name}", "data"]], {"name": "first/last"}],
[[["post", "/v1/{first_name}", "data"]], {"last_name": "last"}],
],
)
def test_transcode_fails(http_options, request_kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you have this test check the exception string?

https://docs.pytest.org/en/6.2.x/assert.html#assertions-about-expected-exceptions

Expand All @@ -385,5 +386,4 @@ def helper_test_transcode(http_options_list, expected_result_list):
}
if expected_result_list[2]:
expected_result["body"] = expected_result_list[2]

return (http_options, expected_result)