aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio_tests/tests/interop/methods.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/grpcio_tests/tests/interop/methods.py')
-rw-r--r--src/python/grpcio_tests/tests/interop/methods.py100
1 files changed, 67 insertions, 33 deletions
diff --git a/src/python/grpcio_tests/tests/interop/methods.py b/src/python/grpcio_tests/tests/interop/methods.py
index ae9a50dd9b..b728ffd704 100644
--- a/src/python/grpcio_tests/tests/interop/methods.py
+++ b/src/python/grpcio_tests/tests/interop/methods.py
@@ -62,9 +62,10 @@ class TestService(test_pb2_grpc.TestServiceServicer):
def UnaryCall(self, request, context):
_maybe_echo_metadata(context)
_maybe_echo_status_and_message(request, context)
- return messages_pb2.SimpleResponse(payload=messages_pb2.Payload(
- type=messages_pb2.COMPRESSABLE,
- body=b'\x00' * request.response_size))
+ return messages_pb2.SimpleResponse(
+ payload=messages_pb2.Payload(
+ type=messages_pb2.COMPRESSABLE,
+ body=b'\x00' * request.response_size))
def StreamingOutputCall(self, request, context):
_maybe_echo_status_and_message(request, context)
@@ -100,14 +101,14 @@ class TestService(test_pb2_grpc.TestServiceServicer):
def _expect_status_code(call, expected_code):
if call.code() != expected_code:
- raise ValueError('expected code %s, got %s' %
- (expected_code, call.code()))
+ raise ValueError('expected code %s, got %s' % (expected_code,
+ call.code()))
def _expect_status_details(call, expected_details):
if call.details() != expected_details:
- raise ValueError('expected message %s, got %s' %
- (expected_details, call.details()))
+ raise ValueError('expected message %s, got %s' % (expected_details,
+ call.details()))
def _validate_status_code_and_details(call, expected_code, expected_details):
@@ -152,26 +153,38 @@ def _large_unary(stub):
def _client_streaming(stub):
- payload_body_sizes = (27182, 8, 1828, 45904,)
+ payload_body_sizes = (
+ 27182,
+ 8,
+ 1828,
+ 45904,
+ )
payloads = (messages_pb2.Payload(body=b'\x00' * size)
for size in payload_body_sizes)
requests = (messages_pb2.StreamingInputCallRequest(payload=payload)
for payload in payloads)
response = stub.StreamingInputCall(requests)
if response.aggregated_payload_size != 74922:
- raise ValueError('incorrect size %d!' %
- response.aggregated_payload_size)
+ raise ValueError(
+ 'incorrect size %d!' % response.aggregated_payload_size)
def _server_streaming(stub):
- sizes = (31415, 9, 2653, 58979,)
+ sizes = (
+ 31415,
+ 9,
+ 2653,
+ 58979,
+ )
request = messages_pb2.StreamingOutputCallRequest(
response_type=messages_pb2.COMPRESSABLE,
- response_parameters=(messages_pb2.ResponseParameters(size=sizes[0]),
- messages_pb2.ResponseParameters(size=sizes[1]),
- messages_pb2.ResponseParameters(size=sizes[2]),
- messages_pb2.ResponseParameters(size=sizes[3]),))
+ response_parameters=(
+ messages_pb2.ResponseParameters(size=sizes[0]),
+ messages_pb2.ResponseParameters(size=sizes[1]),
+ messages_pb2.ResponseParameters(size=sizes[2]),
+ messages_pb2.ResponseParameters(size=sizes[3]),
+ ))
response_iterator = stub.StreamingOutputCall(request)
for index, response in enumerate(response_iterator):
_validate_payload_type_and_length(response, messages_pb2.COMPRESSABLE,
@@ -218,8 +231,18 @@ class _Pipe(object):
def _ping_pong(stub):
- request_response_sizes = (31415, 9, 2653, 58979,)
- request_payload_sizes = (27182, 8, 1828, 45904,)
+ request_response_sizes = (
+ 31415,
+ 9,
+ 2653,
+ 58979,
+ )
+ request_payload_sizes = (
+ 27182,
+ 8,
+ 1828,
+ 45904,
+ )
with _Pipe() as pipe:
response_iterator = stub.FullDuplexCall(pipe)
@@ -247,8 +270,18 @@ def _cancel_after_begin(stub):
def _cancel_after_first_response(stub):
- request_response_sizes = (31415, 9, 2653, 58979,)
- request_payload_sizes = (27182, 8, 1828, 45904,)
+ request_response_sizes = (
+ 31415,
+ 9,
+ 2653,
+ 58979,
+ )
+ request_payload_sizes = (
+ 27182,
+ 8,
+ 1828,
+ 45904,
+ )
with _Pipe() as pipe:
response_iterator = stub.FullDuplexCall(pipe)
@@ -331,14 +364,14 @@ def _status_code_and_message(stub):
def _unimplemented_method(test_service_stub):
- response_future = (
- test_service_stub.UnimplementedCall.future(empty_pb2.Empty()))
+ response_future = (test_service_stub.UnimplementedCall.future(
+ empty_pb2.Empty()))
_expect_status_code(response_future, grpc.StatusCode.UNIMPLEMENTED)
def _unimplemented_service(unimplemented_service_stub):
- response_future = (
- unimplemented_service_stub.UnimplementedCall.future(empty_pb2.Empty()))
+ response_future = (unimplemented_service_stub.UnimplementedCall.future(
+ empty_pb2.Empty()))
_expect_status_code(response_future, grpc.StatusCode.UNIMPLEMENTED)
@@ -392,11 +425,12 @@ def _oauth2_auth_token(stub, args):
wanted_email = json.load(open(json_key_filename, 'rb'))['client_email']
response = _large_unary_common_behavior(stub, True, True, None)
if wanted_email != response.username:
- raise ValueError('expected username %s, got %s' %
- (wanted_email, response.username))
+ raise ValueError('expected username %s, got %s' % (wanted_email,
+ response.username))
if args.oauth_scope.find(response.oauth_scope) == -1:
- raise ValueError('expected to find oauth scope "{}" in received "{}"'.
- format(response.oauth_scope, args.oauth_scope))
+ raise ValueError(
+ 'expected to find oauth scope "{}" in received "{}"'.format(
+ response.oauth_scope, args.oauth_scope))
def _jwt_token_creds(stub, args):
@@ -404,8 +438,8 @@ def _jwt_token_creds(stub, args):
wanted_email = json.load(open(json_key_filename, 'rb'))['client_email']
response = _large_unary_common_behavior(stub, True, False, None)
if wanted_email != response.username:
- raise ValueError('expected username %s, got %s' %
- (wanted_email, response.username))
+ raise ValueError('expected username %s, got %s' % (wanted_email,
+ response.username))
def _per_rpc_creds(stub, args):
@@ -419,8 +453,8 @@ def _per_rpc_creds(stub, args):
request=google_auth_transport_requests.Request()))
response = _large_unary_common_behavior(stub, True, False, call_credentials)
if wanted_email != response.username:
- raise ValueError('expected username %s, got %s' %
- (wanted_email, response.username))
+ raise ValueError('expected username %s, got %s' % (wanted_email,
+ response.username))
@enum.unique
@@ -479,5 +513,5 @@ class TestCase(enum.Enum):
elif self is TestCase.PER_RPC_CREDS:
_per_rpc_creds(stub, args)
else:
- raise NotImplementedError('Test case "%s" not implemented!' %
- self.name)
+ raise NotImplementedError(
+ 'Test case "%s" not implemented!' % self.name)