-
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: add field headers for other http verbs #443
Conversation
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.
Looks good, just some nitpicky codegolf on my end :P
I'll look into why the tests are failing.
Ahh, it looks like the generated unit tests aren't getting 100% coverage. |
Codecov Report
@@ Coverage Diff @@
## master #443 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 26 26
Lines 1453 1453
Branches 300 300
=========================================
Hits 1453 1453
Continue to review full report at Codecov.
|
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.
It looks like the last failing unit test is for a streaming method that uses field headers.
|
||
# Mock the actual call within the gRPC stub, and fake the request. | ||
with mock.patch.object( | ||
type(client._transport.{{ method.name|snake_case }}), | ||
'__call__') as call: | ||
{% if method.void -%} |
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.
Copy-pasted from the unit test below this.
) | ||
request = {{ method.input.ident }}() | ||
|
||
{%- for field_header in method.field_headers %} |
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.
Tweaking this slightly for field headers like "/v1beta1/{endpoint.name=projects/*/locations/*/namespaces/*/services/*/endpoints/*}"
@@ -333,7 +333,9 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta): | |||
metadata = tuple(metadata) + ( | |||
gapic_v1.routing_header.to_grpc_metadata(( | |||
{%- for field_header in method.field_headers %} | |||
{%- if not method.client_streaming %} |
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.
Added this for a failing showcase test (see streaming method in proto and failing test).
Not sure if this is the right call though. What's the correct way to handle metadata/headers for streaming methods? @software-dov
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.
I was under the impression that headers for streaming methods don't make a lot of sense because they're not tightly bound to http semantics. If that's not correct, then I think we would need to ask someone who knows better.
@@ -333,7 +333,9 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta): | |||
metadata = tuple(metadata) + ( | |||
gapic_v1.routing_header.to_grpc_metadata(( | |||
{%- for field_header in method.field_headers %} | |||
{%- if not method.client_streaming %} |
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.
I was under the impression that headers for streaming methods don't make a lot of sense because they're not tightly bound to http semantics. If that's not correct, then I think we would need to ask someone who knows better.
Closes #401