aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/operations_v1
diff options
context:
space:
mode:
authorBu Sun Kim <8822365+busunkim96@users.noreply.github.com>2021-01-14 14:22:58 -0700
committerGitHub <noreply@github.com>2021-01-14 14:22:58 -0700
commit73854e897b885e9be290f2676a8a1466b4f041e4 (patch)
tree2875e9e955945d98cea7e58c8e672d26faac8948 /tests/unit/operations_v1
parentc5fee8947b466484b4dc40a482db4b89415c3e51 (diff)
downloadpython-api-core-73854e897b885e9be290f2676a8a1466b4f041e4.tar.gz
feat: allow gRPC metadata to be passed to operations client (#127)
Diffstat (limited to 'tests/unit/operations_v1')
-rw-r--r--tests/unit/operations_v1/test_operations_client.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/unit/operations_v1/test_operations_client.py b/tests/unit/operations_v1/test_operations_client.py
index cc57461..bd7f373 100644
--- a/tests/unit/operations_v1/test_operations_client.py
+++ b/tests/unit/operations_v1/test_operations_client.py
@@ -24,8 +24,9 @@ def test_get_operation():
client = operations_v1.OperationsClient(channel)
channel.GetOperation.response = operations_pb2.Operation(name="meep")
- response = client.get_operation("name")
+ response = client.get_operation("name", metadata=[("x-goog-request-params", "foo")])
+ assert ("x-goog-request-params", "foo") in channel.GetOperation.calls[0].metadata
assert len(channel.GetOperation.requests) == 1
assert channel.GetOperation.requests[0].name == "name"
assert response == channel.GetOperation.response
@@ -41,11 +42,12 @@ def test_list_operations():
list_response = operations_pb2.ListOperationsResponse(operations=operations)
channel.ListOperations.response = list_response
- response = client.list_operations("name", "filter")
+ response = client.list_operations("name", "filter", metadata=[("x-goog-request-params", "foo")])
assert isinstance(response, page_iterator.Iterator)
assert list(response) == operations
+ assert ("x-goog-request-params", "foo") in channel.ListOperations.calls[0].metadata
assert len(channel.ListOperations.requests) == 1
request = channel.ListOperations.requests[0]
assert isinstance(request, operations_pb2.ListOperationsRequest)
@@ -58,8 +60,9 @@ def test_delete_operation():
client = operations_v1.OperationsClient(channel)
channel.DeleteOperation.response = empty_pb2.Empty()
- client.delete_operation("name")
+ client.delete_operation("name", metadata=[("x-goog-request-params", "foo")])
+ assert ("x-goog-request-params", "foo") in channel.DeleteOperation.calls[0].metadata
assert len(channel.DeleteOperation.requests) == 1
assert channel.DeleteOperation.requests[0].name == "name"
@@ -69,7 +72,8 @@ def test_cancel_operation():
client = operations_v1.OperationsClient(channel)
channel.CancelOperation.response = empty_pb2.Empty()
- client.cancel_operation("name")
+ client.cancel_operation("name", metadata=[("x-goog-request-params", "foo")])
+ assert ("x-goog-request-params", "foo") in channel.CancelOperation.calls[0].metadata
assert len(channel.CancelOperation.requests) == 1
assert channel.CancelOperation.requests[0].name == "name"