Commit 37589f3
tests: forward compatible fix for google-cloud-monitoring (#13379)
Towards #13356
This PR fixes the issue seen in PR
#13359 where
presubmits fail with
```
> thunk = lambda m: self._channel.unary_unary(
m,
request_serializer,
response_deserializer,
_registered_method,
)
E TypeError: ChannelStub.unary_unary() takes from 2 to 4 positional arguments but 5 were given
```
The reason for the failures is that in
https://github.com/googleapis/gapic-generator-python/pull/2284/files
support for debug logging was added, which required using grpc
[intercept_channel](https://github.com/googleapis/gapic-generator-python/blob/e050f4eb3eddfe150f028a2a2bd901899afb965a/gapic/templates/%25namespace/%25name_%25version/%25sub/services/%25service/transports/grpc.py.j2#L281)
and there is a slight different in the [standard gRPC channel
](https://github.com/grpc/grpc/blob/b53f4055a93fb98601c75dcefaa8f3665167e6cf/src/python/grpcio/grpc/_channel.py#L2126
)and the
[intercept_channel](https://github.com/grpc/grpc/blob/b53f4055a93fb98601c75dcefaa8f3665167e6cf/src/python/grpcio/grpc/_interceptor.py#L688).
If gRPC is mocked, it needs to be compatible with
[intercept_channel](https://github.com/grpc/grpc/blob/b53f4055a93fb98601c75dcefaa8f3665167e6cf/src/python/grpcio/grpc/_interceptor.py#L688).
The issue, as seen in the stack trace, is that `unary_unary`
[here](https://github.com/grpc/grpc/blob/b53f4055a93fb98601c75dcefaa8f3665167e6cf/src/python/grpcio/grpc/_interceptor.py#L696-L701)
expects an additional parameter `_registered_method` in the method
signature of `unary_unary` however the stub code below for `unary_unary`
does not have this parameter.
https://github.com/googleapis/google-cloud-python/blob/9b2f079a87eb30c75bc25bd339471c3a35a4f1fc/packages/google-cloud-monitoring/tests/unit/test_query.py#L87
In addition, the grpc code
[here](https://github.com/grpc/grpc/blob/b53f4055a93fb98601c75dcefaa8f3665167e6cf/src/python/grpcio/grpc/_interceptor.py#L516-L525)
also expects `with_call` which needs to be added as well. Also see
https://github.com/grpc/grpc/blob/b53f4055a93fb98601c75dcefaa8f3665167e6cf/src/python/grpcio/grpc/_interceptor.py#L277-L284
---------
Co-authored-by: Victor Chudnovsky <[email protected]>1 parent 9b2f079 commit 37589f3
1 file changed
+28
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
76 | 94 | | |
77 | 95 | | |
78 | 96 | | |
| |||
84 | 102 | | |
85 | 103 | | |
86 | 104 | | |
87 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
88 | 115 | | |
89 | 116 | | |
90 | 117 | | |
| |||
0 commit comments