aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio_tests/tests/unit
diff options
context:
space:
mode:
authorGravatar ncteisen <ncteisen@gmail.com>2018-01-09 13:49:37 -0800
committerGravatar ncteisen <ncteisen@gmail.com>2018-01-09 13:49:37 -0800
commitb04efac6a5ac0842bc2b6c3e72b786b646644ac0 (patch)
treeca70be08a55ea3aeade97e226b232b1786c63656 /src/python/grpcio_tests/tests/unit
parentb928fd496efbe2265169077bcfdf684f7ad6aea3 (diff)
parent0ea629c61ec70a35075e800bc3f85651f00e746f (diff)
Merge branch 'master' of https://github.com/grpc/grpc into channel-tracing
Diffstat (limited to 'src/python/grpcio_tests/tests/unit')
-rw-r--r--src/python/grpcio_tests/tests/unit/_api_test.py84
-rw-r--r--src/python/grpcio_tests/tests/unit/_auth_context_test.py13
-rw-r--r--src/python/grpcio_tests/tests/unit/_channel_args_test.py9
-rw-r--r--src/python/grpcio_tests/tests/unit/_compression_test.py8
-rw-r--r--src/python/grpcio_tests/tests/unit/_credentials_test.py4
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py44
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_channel_test.py5
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_common.py23
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py66
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py64
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py46
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_server_test.py49
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py172
-rw-r--r--src/python/grpcio_tests/tests/unit/_empty_message_test.py8
-rw-r--r--src/python/grpcio_tests/tests/unit/_interceptor_test.py158
-rw-r--r--src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py16
-rw-r--r--src/python/grpcio_tests/tests/unit/_invocation_defects_test.py24
-rw-r--r--src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py48
-rw-r--r--src/python/grpcio_tests/tests/unit/_metadata_test.py54
-rw-r--r--src/python/grpcio_tests/tests/unit/_rpc_test.py132
-rw-r--r--src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py3
-rw-r--r--src/python/grpcio_tests/tests/unit/_thread_cleanup_test.py4
-rw-r--r--src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py10
-rw-r--r--src/python/grpcio_tests/tests/unit/beta/_face_interface_test.py19
-rw-r--r--src/python/grpcio_tests/tests/unit/beta/_implementations_test.py4
-rw-r--r--src/python/grpcio_tests/tests/unit/beta/test_utilities.py6
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py72
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/_digest.py22
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py104
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/_invocation.py7
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/_stock_service.py4
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/test_cases.py8
-rw-r--r--src/python/grpcio_tests/tests/unit/resources.py6
-rw-r--r--src/python/grpcio_tests/tests/unit/test_common.py24
34 files changed, 789 insertions, 531 deletions
diff --git a/src/python/grpcio_tests/tests/unit/_api_test.py b/src/python/grpcio_tests/tests/unit/_api_test.py
index d6f4447532..f6245be77d 100644
--- a/src/python/grpcio_tests/tests/unit/_api_test.py
+++ b/src/python/grpcio_tests/tests/unit/_api_test.py
@@ -26,28 +26,57 @@ class AllTest(unittest.TestCase):
def testAll(self):
expected_grpc_code_elements = (
- 'FutureTimeoutError', 'FutureCancelledError', 'Future',
- 'ChannelConnectivity', 'StatusCode', 'RpcError', 'RpcContext',
- 'Call', 'ChannelCredentials', 'CallCredentials',
- 'AuthMetadataContext', 'AuthMetadataPluginCallback',
- 'AuthMetadataPlugin', 'ServerCertificateConfiguration',
- 'ServerCredentials', 'UnaryUnaryMultiCallable',
- 'UnaryStreamMultiCallable', 'StreamUnaryMultiCallable',
- 'StreamStreamMultiCallable', 'UnaryUnaryClientInterceptor',
- 'UnaryStreamClientInterceptor', 'StreamUnaryClientInterceptor',
- 'StreamStreamClientInterceptor', 'Channel', 'ServicerContext',
- 'RpcMethodHandler', 'HandlerCallDetails', 'GenericRpcHandler',
- 'ServiceRpcHandler', 'Server', 'ServerInterceptor',
- 'unary_unary_rpc_method_handler', 'unary_stream_rpc_method_handler',
- 'stream_unary_rpc_method_handler', 'ClientCallDetails',
+ 'FutureTimeoutError',
+ 'FutureCancelledError',
+ 'Future',
+ 'ChannelConnectivity',
+ 'StatusCode',
+ 'RpcError',
+ 'RpcContext',
+ 'Call',
+ 'ChannelCredentials',
+ 'CallCredentials',
+ 'AuthMetadataContext',
+ 'AuthMetadataPluginCallback',
+ 'AuthMetadataPlugin',
+ 'ServerCertificateConfiguration',
+ 'ServerCredentials',
+ 'UnaryUnaryMultiCallable',
+ 'UnaryStreamMultiCallable',
+ 'StreamUnaryMultiCallable',
+ 'StreamStreamMultiCallable',
+ 'UnaryUnaryClientInterceptor',
+ 'UnaryStreamClientInterceptor',
+ 'StreamUnaryClientInterceptor',
+ 'StreamStreamClientInterceptor',
+ 'Channel',
+ 'ServicerContext',
+ 'RpcMethodHandler',
+ 'HandlerCallDetails',
+ 'GenericRpcHandler',
+ 'ServiceRpcHandler',
+ 'Server',
+ 'ServerInterceptor',
+ 'unary_unary_rpc_method_handler',
+ 'unary_stream_rpc_method_handler',
+ 'stream_unary_rpc_method_handler',
+ 'ClientCallDetails',
'stream_stream_rpc_method_handler',
- 'method_handlers_generic_handler', 'ssl_channel_credentials',
- 'metadata_call_credentials', 'access_token_call_credentials',
- 'composite_call_credentials', 'composite_channel_credentials',
- 'ssl_server_credentials', 'ssl_server_certificate_configuration',
- 'dynamic_ssl_server_credentials', 'channel_ready_future',
- 'insecure_channel', 'secure_channel', 'intercept_channel',
- 'server',)
+ 'method_handlers_generic_handler',
+ 'ssl_channel_credentials',
+ 'metadata_call_credentials',
+ 'access_token_call_credentials',
+ 'composite_call_credentials',
+ 'composite_channel_credentials',
+ 'ssl_server_credentials',
+ 'ssl_server_certificate_configuration',
+ 'dynamic_ssl_server_credentials',
+ 'channel_ready_future',
+ 'insecure_channel',
+ 'secure_channel',
+ 'intercept_channel',
+ 'server',
+ )
six.assertCountEqual(self, expected_grpc_code_elements,
_from_grpc_import_star.GRPC_ELEMENTS)
@@ -56,12 +85,13 @@ class AllTest(unittest.TestCase):
class ChannelConnectivityTest(unittest.TestCase):
def testChannelConnectivity(self):
- self.assertSequenceEqual(
- (grpc.ChannelConnectivity.IDLE, grpc.ChannelConnectivity.CONNECTING,
- grpc.ChannelConnectivity.READY,
- grpc.ChannelConnectivity.TRANSIENT_FAILURE,
- grpc.ChannelConnectivity.SHUTDOWN,),
- tuple(grpc.ChannelConnectivity))
+ self.assertSequenceEqual((
+ grpc.ChannelConnectivity.IDLE,
+ grpc.ChannelConnectivity.CONNECTING,
+ grpc.ChannelConnectivity.READY,
+ grpc.ChannelConnectivity.TRANSIENT_FAILURE,
+ grpc.ChannelConnectivity.SHUTDOWN,
+ ), tuple(grpc.ChannelConnectivity))
class ChannelTest(unittest.TestCase):
diff --git a/src/python/grpcio_tests/tests/unit/_auth_context_test.py b/src/python/grpcio_tests/tests/unit/_auth_context_test.py
index ebc04a71e0..468869a03e 100644
--- a/src/python/grpcio_tests/tests/unit/_auth_context_test.py
+++ b/src/python/grpcio_tests/tests/unit/_auth_context_test.py
@@ -29,8 +29,12 @@ _RESPONSE = b'\x00\x00\x00'
_UNARY_UNARY = '/test/UnaryUnary'
_SERVER_HOST_OVERRIDE = 'foo.test.google.fr'
-_CLIENT_IDS = (b'*.test.google.fr', b'waterzooi.test.google.be',
- b'*.test.youtube.com', b'192.168.1.3',)
+_CLIENT_IDS = (
+ b'*.test.google.fr',
+ b'waterzooi.test.google.be',
+ b'*.test.youtube.com',
+ b'192.168.1.3',
+)
_ID = 'id'
_ID_KEY = 'id_key'
_AUTH_CTX = 'auth_ctx'
@@ -39,7 +43,10 @@ _PRIVATE_KEY = resources.private_key()
_CERTIFICATE_CHAIN = resources.certificate_chain()
_TEST_ROOT_CERTIFICATES = resources.test_root_certificates()
_SERVER_CERTS = ((_PRIVATE_KEY, _CERTIFICATE_CHAIN),)
-_PROPERTY_OPTIONS = (('grpc.ssl_target_name_override', _SERVER_HOST_OVERRIDE,),)
+_PROPERTY_OPTIONS = ((
+ 'grpc.ssl_target_name_override',
+ _SERVER_HOST_OVERRIDE,
+),)
def handle_unary_unary(request, servicer_context):
diff --git a/src/python/grpcio_tests/tests/unit/_channel_args_test.py b/src/python/grpcio_tests/tests/unit/_channel_args_test.py
index 0a6b512866..1a2d2c0117 100644
--- a/src/python/grpcio_tests/tests/unit/_channel_args_test.py
+++ b/src/python/grpcio_tests/tests/unit/_channel_args_test.py
@@ -24,8 +24,13 @@ class TestPointerWrapper(object):
return 123456
-TEST_CHANNEL_ARGS = (('arg1', b'bytes_val'), ('arg2', 'str_val'), ('arg3', 1),
- (b'arg4', 'str_val'), ('arg6', TestPointerWrapper()),)
+TEST_CHANNEL_ARGS = (
+ ('arg1', b'bytes_val'),
+ ('arg2', 'str_val'),
+ ('arg3', 1),
+ (b'arg4', 'str_val'),
+ ('arg6', TestPointerWrapper()),
+)
class ChannelArgsTest(unittest.TestCase):
diff --git a/src/python/grpcio_tests/tests/unit/_compression_test.py b/src/python/grpcio_tests/tests/unit/_compression_test.py
index 93e599d8f8..7550cd39ba 100644
--- a/src/python/grpcio_tests/tests/unit/_compression_test.py
+++ b/src/python/grpcio_tests/tests/unit/_compression_test.py
@@ -26,16 +26,16 @@ _STREAM_STREAM = '/test/StreamStream'
def handle_unary(request, servicer_context):
- servicer_context.send_initial_metadata(
- [('grpc-internal-encoding-request', 'gzip')])
+ servicer_context.send_initial_metadata([('grpc-internal-encoding-request',
+ 'gzip')])
return request
def handle_stream(request_iterator, servicer_context):
# TODO(issue:#6891) We should be able to remove this loop,
# and replace with return; yield
- servicer_context.send_initial_metadata(
- [('grpc-internal-encoding-request', 'gzip')])
+ servicer_context.send_initial_metadata([('grpc-internal-encoding-request',
+ 'gzip')])
for request in request_iterator:
yield request
diff --git a/src/python/grpcio_tests/tests/unit/_credentials_test.py b/src/python/grpcio_tests/tests/unit/_credentials_test.py
index 097898b987..f487fe66a2 100644
--- a/src/python/grpcio_tests/tests/unit/_credentials_test.py
+++ b/src/python/grpcio_tests/tests/unit/_credentials_test.py
@@ -26,8 +26,8 @@ class CredentialsTest(unittest.TestCase):
third = grpc.access_token_call_credentials('ghi')
first_and_second = grpc.composite_call_credentials(first, second)
- first_second_and_third = grpc.composite_call_credentials(first, second,
- third)
+ first_second_and_third = grpc.composite_call_credentials(
+ first, second, third)
self.assertIsInstance(first_and_second, grpc.CallCredentials)
self.assertIsInstance(first_second_and_third, grpc.CallCredentials)
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py b/src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py
index 7df8e2fde6..b81d6fbc61 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py
@@ -53,7 +53,7 @@ class _Handler(object):
self._state = state
self._lock = threading.Lock()
self._completion_queue = completion_queue
- self._call = rpc_event.operation_call
+ self._call = rpc_event.call
def __call__(self):
with self._state.condition:
@@ -65,10 +65,10 @@ class _Handler(object):
with self._lock:
self._call.start_server_batch(
- (cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS),),
+ (cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),),
_RECEIVE_CLOSE_ON_SERVER_TAG)
self._call.start_server_batch(
- (cygrpc.operation_receive_message(_EMPTY_FLAGS),),
+ (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),),
_RECEIVE_MESSAGE_TAG)
first_event = self._completion_queue.poll()
if _is_cancellation_event(first_event):
@@ -76,12 +76,13 @@ class _Handler(object):
else:
with self._lock:
operations = (
- cygrpc.operation_send_initial_metadata(_EMPTY_METADATA,
- _EMPTY_FLAGS),
- cygrpc.operation_send_message(b'\x79\x57', _EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
+ cygrpc.SendInitialMetadataOperation(_EMPTY_METADATA,
+ _EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(b'\x79\x57', _EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
_EMPTY_METADATA, cygrpc.StatusCode.ok, b'test details!',
- _EMPTY_FLAGS),)
+ _EMPTY_FLAGS),
+ )
self._call.start_server_batch(operations,
_SERVER_COMPLETE_CALL_TAG)
self._completion_queue.poll()
@@ -151,8 +152,12 @@ class CancelManyCallsTest(unittest.TestCase):
state = _State()
- server_thread_args = (state, server, server_completion_queue,
- server_thread_pool,)
+ server_thread_args = (
+ state,
+ server,
+ server_completion_queue,
+ server_thread_pool,
+ )
server_thread = threading.Thread(target=_serve, args=server_thread_args)
server_thread.start()
@@ -170,13 +175,14 @@ class CancelManyCallsTest(unittest.TestCase):
None, _EMPTY_FLAGS, client_completion_queue, b'/twinkies',
None, _INFINITE_FUTURE)
operations = (
- cygrpc.operation_send_initial_metadata(_EMPTY_METADATA,
- _EMPTY_FLAGS),
- cygrpc.operation_send_message(b'\x45\x56', _EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),
- cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),)
+ cygrpc.SendInitialMetadataOperation(_EMPTY_METADATA,
+ _EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(b'\x45\x56', _EMPTY_FLAGS),
+ cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS),
+ )
tag = 'client_complete_call_{0:04d}_tag'.format(index)
client_call.start_client_batch(operations, tag)
client_due.add(tag)
@@ -193,8 +199,8 @@ class CancelManyCallsTest(unittest.TestCase):
state.condition.notify_all()
break
- client_driver.events(test_constants.RPC_CONCURRENCY *
- _SUCCESS_CALL_FRACTION)
+ client_driver.events(
+ test_constants.RPC_CONCURRENCY * _SUCCESS_CALL_FRACTION)
with client_condition:
for client_call in client_calls:
client_call.cancel()
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_channel_test.py b/src/python/grpcio_tests/tests/unit/_cython/_channel_test.py
index 1d57ea7ec1..4eeb34b92e 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_channel_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_channel_test.py
@@ -56,7 +56,10 @@ class ChannelTest(unittest.TestCase):
def test_single_channel_lonely_connectivity(self):
channel, completion_queue = _channel_and_completion_queue()
- _in_parallel(_connectivity_loop, (channel, completion_queue,))
+ _in_parallel(_connectivity_loop, (
+ channel,
+ completion_queue,
+ ))
completion_queue.shutdown()
def test_multiple_channels_lonely_connectivity(self):
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_common.py b/src/python/grpcio_tests/tests/unit/_cython/_common.py
index c5acd36bf2..ffd226fa95 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_common.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_common.py
@@ -23,14 +23,20 @@ RPC_COUNT = 4000
INFINITE_FUTURE = cygrpc.Timespec(float('+inf'))
EMPTY_FLAGS = 0
-INVOCATION_METADATA = (('client-md-key', 'client-md-key'),
- ('client-md-key-bin', b'\x00\x01' * 3000),)
+INVOCATION_METADATA = (
+ ('client-md-key', 'client-md-key'),
+ ('client-md-key-bin', b'\x00\x01' * 3000),
+)
-INITIAL_METADATA = (('server-initial-md-key', 'server-initial-md-value'),
- ('server-initial-md-key-bin', b'\x00\x02' * 3000),)
+INITIAL_METADATA = (
+ ('server-initial-md-key', 'server-initial-md-value'),
+ ('server-initial-md-key-bin', b'\x00\x02' * 3000),
+)
-TRAILING_METADATA = (('server-trailing-md-key', 'server-trailing-md-value'),
- ('server-trailing-md-key-bin', b'\x00\x03' * 3000),)
+TRAILING_METADATA = (
+ ('server-trailing-md-key', 'server-trailing-md-value'),
+ ('server-trailing-md-key-bin', b'\x00\x03' * 3000),
+)
class QueueDriver(object):
@@ -76,7 +82,10 @@ def execute_many_times(behavior):
class OperationResult(
collections.namedtuple('OperationResult', (
- 'start_batch_result', 'completion_type', 'success',))):
+ 'start_batch_result',
+ 'completion_type',
+ 'success',
+ ))):
pass
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py b/src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py
index d08003af44..4ef4ad33e5 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py
@@ -49,18 +49,19 @@ class Test(_common.RpcTest, unittest.TestCase):
with self.client_condition:
client_receive_initial_metadata_start_batch_result = (
client_call.start_client_batch([
- cygrpc.operation_receive_initial_metadata(
- _common.EMPTY_FLAGS),
+ cygrpc.ReceiveInitialMetadataOperation(_common.EMPTY_FLAGS),
], client_receive_initial_metadata_tag))
+ self.assertEqual(cygrpc.CallError.ok,
+ client_receive_initial_metadata_start_batch_result)
client_complete_rpc_start_batch_result = client_call.start_client_batch(
[
- cygrpc.operation_send_initial_metadata(
+ cygrpc.SendInitialMetadataOperation(
_common.INVOCATION_METADATA, _common.EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(
- _common.EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(
- _common.EMPTY_FLAGS),
+ cygrpc.SendCloseFromClientOperation(_common.EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_common.EMPTY_FLAGS),
], client_complete_rpc_tag)
+ self.assertEqual(cygrpc.CallError.ok,
+ client_complete_rpc_start_batch_result)
self.client_driver.add_due({
client_receive_initial_metadata_tag,
client_complete_rpc_tag,
@@ -71,8 +72,8 @@ class Test(_common.RpcTest, unittest.TestCase):
with server_call_condition:
server_send_initial_metadata_start_batch_result = (
- server_request_call_event.operation_call.start_server_batch([
- cygrpc.operation_send_initial_metadata(
+ server_request_call_event.call.start_server_batch([
+ cygrpc.SendInitialMetadataOperation(
_common.INITIAL_METADATA, _common.EMPTY_FLAGS),
], server_send_initial_metadata_tag))
server_call_driver.add_due({
@@ -83,10 +84,9 @@ class Test(_common.RpcTest, unittest.TestCase):
with server_call_condition:
server_complete_rpc_start_batch_result = (
- server_request_call_event.operation_call.start_server_batch([
- cygrpc.operation_receive_close_on_server(
- _common.EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
+ server_request_call_event.call.start_server_batch([
+ cygrpc.ReceiveCloseOnServerOperation(_common.EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
_common.TRAILING_METADATA, cygrpc.StatusCode.ok,
b'test details', _common.EMPTY_FLAGS),
], server_complete_rpc_tag))
@@ -101,27 +101,29 @@ class Test(_common.RpcTest, unittest.TestCase):
client_complete_rpc_event = self.client_driver.event_with_tag(
client_complete_rpc_tag)
- return (_common.OperationResult(server_request_call_start_batch_result,
- server_request_call_event.type,
- server_request_call_event.success),
- _common.OperationResult(
- client_receive_initial_metadata_start_batch_result,
- client_receive_initial_metadata_event.type,
- client_receive_initial_metadata_event.success),
- _common.OperationResult(client_complete_rpc_start_batch_result,
- client_complete_rpc_event.type,
- client_complete_rpc_event.success),
- _common.OperationResult(
- server_send_initial_metadata_start_batch_result,
- server_send_initial_metadata_event.type,
- server_send_initial_metadata_event.success),
- _common.OperationResult(server_complete_rpc_start_batch_result,
- server_complete_rpc_event.type,
- server_complete_rpc_event.success),)
+ return (
+ _common.OperationResult(server_request_call_start_batch_result,
+ server_request_call_event.completion_type,
+ server_request_call_event.success),
+ _common.OperationResult(
+ client_receive_initial_metadata_start_batch_result,
+ client_receive_initial_metadata_event.completion_type,
+ client_receive_initial_metadata_event.success),
+ _common.OperationResult(client_complete_rpc_start_batch_result,
+ client_complete_rpc_event.completion_type,
+ client_complete_rpc_event.success),
+ _common.OperationResult(
+ server_send_initial_metadata_start_batch_result,
+ server_send_initial_metadata_event.completion_type,
+ server_send_initial_metadata_event.success),
+ _common.OperationResult(server_complete_rpc_start_batch_result,
+ server_complete_rpc_event.completion_type,
+ server_complete_rpc_event.success),
+ )
def test_rpcs(self):
- expecteds = [(_common.SUCCESSFUL_OPERATION_RESULT,) *
- 5] * _common.RPC_COUNT
+ expecteds = [(
+ _common.SUCCESSFUL_OPERATION_RESULT,) * 5] * _common.RPC_COUNT
actuallys = _common.execute_many_times(self._do_rpcs)
self.assertSequenceEqual(expecteds, actuallys)
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py b/src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py
index d0166a2b29..85395c9680 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py
@@ -44,17 +44,14 @@ class Test(_common.RpcTest, unittest.TestCase):
with self.client_condition:
client_receive_initial_metadata_start_batch_result = (
client_call.start_client_batch([
- cygrpc.operation_receive_initial_metadata(
- _common.EMPTY_FLAGS),
+ cygrpc.ReceiveInitialMetadataOperation(_common.EMPTY_FLAGS),
], client_receive_initial_metadata_tag))
client_complete_rpc_start_batch_result = client_call.start_client_batch(
[
- cygrpc.operation_send_initial_metadata(
+ cygrpc.SendInitialMetadataOperation(
_common.INVOCATION_METADATA, _common.EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(
- _common.EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(
- _common.EMPTY_FLAGS),
+ cygrpc.SendCloseFromClientOperation(_common.EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_common.EMPTY_FLAGS),
], client_complete_rpc_tag)
self.client_driver.add_due({
client_receive_initial_metadata_tag,
@@ -66,8 +63,8 @@ class Test(_common.RpcTest, unittest.TestCase):
with self.server_condition:
server_send_initial_metadata_start_batch_result = (
- server_request_call_event.operation_call.start_server_batch([
- cygrpc.operation_send_initial_metadata(
+ server_request_call_event.call.start_server_batch([
+ cygrpc.SendInitialMetadataOperation(
_common.INITIAL_METADATA, _common.EMPTY_FLAGS),
], server_send_initial_metadata_tag))
self.server_driver.add_due({
@@ -78,12 +75,11 @@ class Test(_common.RpcTest, unittest.TestCase):
with self.server_condition:
server_complete_rpc_start_batch_result = (
- server_request_call_event.operation_call.start_server_batch([
- cygrpc.operation_receive_close_on_server(
- _common.EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
+ server_request_call_event.call.start_server_batch([
+ cygrpc.ReceiveCloseOnServerOperation(_common.EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
_common.TRAILING_METADATA, cygrpc.StatusCode.ok,
- b'test details', _common.EMPTY_FLAGS),
+ 'test details', _common.EMPTY_FLAGS),
], server_complete_rpc_tag))
self.server_driver.add_due({
server_complete_rpc_tag,
@@ -96,27 +92,29 @@ class Test(_common.RpcTest, unittest.TestCase):
client_complete_rpc_event = self.client_driver.event_with_tag(
client_complete_rpc_tag)
- return (_common.OperationResult(server_request_call_start_batch_result,
- server_request_call_event.type,
- server_request_call_event.success),
- _common.OperationResult(
- client_receive_initial_metadata_start_batch_result,
- client_receive_initial_metadata_event.type,
- client_receive_initial_metadata_event.success),
- _common.OperationResult(client_complete_rpc_start_batch_result,
- client_complete_rpc_event.type,
- client_complete_rpc_event.success),
- _common.OperationResult(
- server_send_initial_metadata_start_batch_result,
- server_send_initial_metadata_event.type,
- server_send_initial_metadata_event.success),
- _common.OperationResult(server_complete_rpc_start_batch_result,
- server_complete_rpc_event.type,
- server_complete_rpc_event.success),)
+ return (
+ _common.OperationResult(server_request_call_start_batch_result,
+ server_request_call_event.completion_type,
+ server_request_call_event.success),
+ _common.OperationResult(
+ client_receive_initial_metadata_start_batch_result,
+ client_receive_initial_metadata_event.completion_type,
+ client_receive_initial_metadata_event.success),
+ _common.OperationResult(client_complete_rpc_start_batch_result,
+ client_complete_rpc_event.completion_type,
+ client_complete_rpc_event.success),
+ _common.OperationResult(
+ server_send_initial_metadata_start_batch_result,
+ server_send_initial_metadata_event.completion_type,
+ server_send_initial_metadata_event.success),
+ _common.OperationResult(server_complete_rpc_start_batch_result,
+ server_complete_rpc_event.completion_type,
+ server_complete_rpc_event.success),
+ )
def test_rpcs(self):
- expecteds = [(_common.SUCCESSFUL_OPERATION_RESULT,) *
- 5] * _common.RPC_COUNT
+ expecteds = [(
+ _common.SUCCESSFUL_OPERATION_RESULT,) * 5] * _common.RPC_COUNT
actuallys = _common.execute_many_times(self._do_rpcs)
self.assertSequenceEqual(expecteds, actuallys)
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py b/src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py
index c7d19058da..82ef25b2a7 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py
@@ -137,9 +137,12 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
server_send_first_message_tag = 'server_send_first_message_tag'
server_send_second_message_tag = 'server_send_second_message_tag'
server_complete_rpc_tag = 'server_complete_rpc_tag'
- server_call_due = set(
- (server_send_initial_metadata_tag, server_send_first_message_tag,
- server_send_second_message_tag, server_complete_rpc_tag,))
+ server_call_due = set((
+ server_send_initial_metadata_tag,
+ server_send_first_message_tag,
+ server_send_second_message_tag,
+ server_complete_rpc_tag,
+ ))
server_call_completion_queue = cygrpc.CompletionQueue()
server_call_driver = _QueueDriver(server_call_condition,
server_call_completion_queue,
@@ -159,15 +162,15 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
with client_condition:
client_receive_initial_metadata_start_batch_result = (
client_call.start_client_batch([
- cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),
+ cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),
], client_receive_initial_metadata_tag))
client_due.add(client_receive_initial_metadata_tag)
client_complete_rpc_start_batch_result = (
client_call.start_client_batch([
- cygrpc.operation_send_initial_metadata(_EMPTY_METADATA,
- _EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),
+ cygrpc.SendInitialMetadataOperation(_EMPTY_METADATA,
+ _EMPTY_FLAGS),
+ cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS),
], client_complete_rpc_tag))
client_due.add(client_complete_rpc_tag)
@@ -175,13 +178,13 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
with server_call_condition:
server_send_initial_metadata_start_batch_result = (
- server_rpc_event.operation_call.start_server_batch([
- cygrpc.operation_send_initial_metadata(_EMPTY_METADATA,
- _EMPTY_FLAGS),
+ server_rpc_event.call.start_server_batch([
+ cygrpc.SendInitialMetadataOperation(_EMPTY_METADATA,
+ _EMPTY_FLAGS),
], server_send_initial_metadata_tag))
server_send_first_message_start_batch_result = (
- server_rpc_event.operation_call.start_server_batch([
- cygrpc.operation_send_message(b'\x07', _EMPTY_FLAGS),
+ server_rpc_event.call.start_server_batch([
+ cygrpc.SendMessageOperation(b'\x07', _EMPTY_FLAGS),
], server_send_first_message_tag))
server_send_initial_metadata_event = server_call_driver.event_with_tag(
server_send_initial_metadata_tag)
@@ -189,13 +192,13 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
server_send_first_message_tag)
with server_call_condition:
server_send_second_message_start_batch_result = (
- server_rpc_event.operation_call.start_server_batch([
- cygrpc.operation_send_message(b'\x07', _EMPTY_FLAGS),
+ server_rpc_event.call.start_server_batch([
+ cygrpc.SendMessageOperation(b'\x07', _EMPTY_FLAGS),
], server_send_second_message_tag))
server_complete_rpc_start_batch_result = (
- server_rpc_event.operation_call.start_server_batch([
- cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
+ server_rpc_event.call.start_server_batch([
+ cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
(), cygrpc.StatusCode.ok, b'test details',
_EMPTY_FLAGS),
], server_complete_rpc_tag))
@@ -209,7 +212,7 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
client_receive_first_message_tag = 'client_receive_first_message_tag'
client_receive_first_message_start_batch_result = (
client_call.start_client_batch([
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
], client_receive_first_message_tag))
client_due.add(client_receive_first_message_tag)
client_receive_first_message_event = client_driver.event_with_tag(
@@ -232,9 +235,8 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
self.assertEqual(cygrpc.CallError.ok, client_call_cancel_result)
self.assertIs(server_rpc_tag, server_rpc_event.tag)
self.assertEqual(cygrpc.CompletionType.operation_complete,
- server_rpc_event.type)
- self.assertIsInstance(server_rpc_event.operation_call, cygrpc.Call)
- self.assertEqual(0, len(server_rpc_event.batch_operations))
+ server_rpc_event.completion_type)
+ self.assertIsInstance(server_rpc_event.call, cygrpc.Call)
if __name__ == '__main__':
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_server_test.py b/src/python/grpcio_tests/tests/unit/_cython/_server_test.py
new file mode 100644
index 0000000000..12bf40be6b
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/_cython/_server_test.py
@@ -0,0 +1,49 @@
+# Copyright 2017 gRPC authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""Test servers at the level of the Cython API."""
+
+import threading
+import time
+import unittest
+
+from grpc._cython import cygrpc
+
+
+class Test(unittest.TestCase):
+
+ def test_lonely_server(self):
+ server_call_completion_queue = cygrpc.CompletionQueue()
+ server_shutdown_completion_queue = cygrpc.CompletionQueue()
+ server = cygrpc.Server(cygrpc.ChannelArgs([]))
+ server.register_completion_queue(server_call_completion_queue)
+ server.register_completion_queue(server_shutdown_completion_queue)
+ port = server.add_http2_port(b'[::]:0')
+ server.start()
+
+ server_request_call_tag = 'server_request_call_tag'
+ server_request_call_start_batch_result = server.request_call(
+ server_call_completion_queue, server_call_completion_queue,
+ server_request_call_tag)
+
+ time.sleep(4)
+
+ server_shutdown_tag = 'server_shutdown_tag'
+ server_shutdown_result = server.shutdown(
+ server_shutdown_completion_queue, server_shutdown_tag)
+ server_request_call_event = server_call_completion_queue.poll()
+ server_shutdown_event = server_shutdown_completion_queue.poll()
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py b/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py
index 33a35ae235..5f9b74ba98 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py
@@ -29,17 +29,14 @@ _EMPTY_FLAGS = 0
def _metadata_plugin(context, callback):
- callback(((_CALL_CREDENTIALS_METADATA_KEY,
- _CALL_CREDENTIALS_METADATA_VALUE,),), cygrpc.StatusCode.ok, b'')
+ callback(((
+ _CALL_CREDENTIALS_METADATA_KEY,
+ _CALL_CREDENTIALS_METADATA_VALUE,
+ ),), cygrpc.StatusCode.ok, b'')
class TypeSmokeTest(unittest.TestCase):
- def testOperationFlags(self):
- operation = cygrpc.operation_send_message(b'asdf',
- cygrpc.WriteFlag.no_compress)
- self.assertEqual(cygrpc.WriteFlag.no_compress, operation.flags)
-
def testTimespec(self):
now = time.time()
now_timespec_a = cygrpc.Timespec(now)
@@ -92,7 +89,8 @@ class TypeSmokeTest(unittest.TestCase):
shutdown_tag = object()
server.shutdown(completion_queue, shutdown_tag)
event = completion_queue.poll()
- self.assertEqual(cygrpc.CompletionType.operation_complete, event.type)
+ self.assertEqual(cygrpc.CompletionType.operation_complete,
+ event.completion_type)
self.assertIs(shutdown_tag, event.tag)
del server
del completion_queue
@@ -117,13 +115,12 @@ class ServerClientMixin(object):
cygrpc.ChannelArg(cygrpc.ChannelArgKey.ssl_target_name_override,
host_override)
])
- self.client_channel = cygrpc.Channel(
- 'localhost:{}'.format(self.port).encode(),
- client_channel_arguments, client_credentials)
+ self.client_channel = cygrpc.Channel('localhost:{}'.format(
+ self.port).encode(), client_channel_arguments,
+ client_credentials)
else:
- self.client_channel = cygrpc.Channel(
- 'localhost:{}'.format(self.port).encode(),
- cygrpc.ChannelArgs([]))
+ self.client_channel = cygrpc.Channel('localhost:{}'.format(
+ self.port).encode(), cygrpc.ChannelArgs([]))
if host_override:
self.host_argument = None # default host
self.expected_host = host_override
@@ -152,12 +149,12 @@ class ServerClientMixin(object):
self.assertEqual(cygrpc.CallError.ok, call_result)
event = queue.poll(deadline)
self.assertEqual(cygrpc.CompletionType.operation_complete,
- event.type)
+ event.completion_type)
self.assertTrue(event.success)
self.assertIs(tag, event.tag)
except Exception as error:
- raise Exception(
- "Error in '{}': {}".format(description, error.message))
+ raise Exception("Error in '{}': {}".format(
+ description, error.message))
return event
return test_utilities.SimpleFuture(performer)
@@ -174,7 +171,7 @@ class ServerClientMixin(object):
SERVER_TRAILING_METADATA_KEY = 'california_is_in_a_drought'
SERVER_TRAILING_METADATA_VALUE = 'zomg it is'
SERVER_STATUS_CODE = cygrpc.StatusCode.ok
- SERVER_STATUS_DETAILS = b'our work is never over'
+ SERVER_STATUS_DETAILS = 'our work is never over'
REQUEST = b'in death a member of project mayhem has a name'
RESPONSE = b'his name is robert paulson'
METHOD = b'twinkies'
@@ -193,16 +190,23 @@ class ServerClientMixin(object):
None, 0, self.client_completion_queue, METHOD, self.host_argument,
cygrpc_deadline)
client_initial_metadata = (
- (CLIENT_METADATA_ASCII_KEY, CLIENT_METADATA_ASCII_VALUE,),
- (CLIENT_METADATA_BIN_KEY, CLIENT_METADATA_BIN_VALUE,),)
+ (
+ CLIENT_METADATA_ASCII_KEY,
+ CLIENT_METADATA_ASCII_VALUE,
+ ),
+ (
+ CLIENT_METADATA_BIN_KEY,
+ CLIENT_METADATA_BIN_VALUE,
+ ),
+ )
client_start_batch_result = client_call.start_client_batch([
- cygrpc.operation_send_initial_metadata(client_initial_metadata,
- _EMPTY_FLAGS),
- cygrpc.operation_send_message(REQUEST, _EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),
- cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS)
+ cygrpc.SendInitialMetadataOperation(client_initial_metadata,
+ _EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(REQUEST, _EMPTY_FLAGS),
+ cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS),
], client_call_tag)
self.assertEqual(cygrpc.CallError.ok, client_start_batch_result)
client_event_future = test_utilities.CompletionQueuePollFuture(
@@ -210,33 +214,35 @@ class ServerClientMixin(object):
request_event = self.server_completion_queue.poll(cygrpc_deadline)
self.assertEqual(cygrpc.CompletionType.operation_complete,
- request_event.type)
- self.assertIsInstance(request_event.operation_call, cygrpc.Call)
+ request_event.completion_type)
+ self.assertIsInstance(request_event.call, cygrpc.Call)
self.assertIs(server_request_tag, request_event.tag)
- self.assertEqual(0, len(request_event.batch_operations))
self.assertTrue(
test_common.metadata_transmitted(client_initial_metadata,
- request_event.request_metadata))
- self.assertEqual(METHOD, request_event.request_call_details.method)
- self.assertEqual(self.expected_host,
- request_event.request_call_details.host)
+ request_event.invocation_metadata))
+ self.assertEqual(METHOD, request_event.call_details.method)
+ self.assertEqual(self.expected_host, request_event.call_details.host)
self.assertLess(
- abs(DEADLINE - float(request_event.request_call_details.deadline)),
+ abs(DEADLINE - float(request_event.call_details.deadline)),
DEADLINE_TOLERANCE)
server_call_tag = object()
- server_call = request_event.operation_call
- server_initial_metadata = (
- (SERVER_INITIAL_METADATA_KEY, SERVER_INITIAL_METADATA_VALUE,),)
- server_trailing_metadata = (
- (SERVER_TRAILING_METADATA_KEY, SERVER_TRAILING_METADATA_VALUE,),)
+ server_call = request_event.call
+ server_initial_metadata = ((
+ SERVER_INITIAL_METADATA_KEY,
+ SERVER_INITIAL_METADATA_VALUE,
+ ),)
+ server_trailing_metadata = ((
+ SERVER_TRAILING_METADATA_KEY,
+ SERVER_TRAILING_METADATA_VALUE,
+ ),)
server_start_batch_result = server_call.start_server_batch([
- cygrpc.operation_send_initial_metadata(
- server_initial_metadata,
- _EMPTY_FLAGS), cygrpc.operation_receive_message(_EMPTY_FLAGS),
- cygrpc.operation_send_message(RESPONSE, _EMPTY_FLAGS),
- cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
+ cygrpc.SendInitialMetadataOperation(server_initial_metadata,
+ _EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(RESPONSE, _EMPTY_FLAGS),
+ cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
server_trailing_metadata, SERVER_STATUS_CODE,
SERVER_STATUS_DETAILS, _EMPTY_FLAGS)
], server_call_tag)
@@ -249,25 +255,24 @@ class ServerClientMixin(object):
found_client_op_types = set()
for client_result in client_event.batch_operations:
# we expect each op type to be unique
- self.assertNotIn(client_result.type, found_client_op_types)
- found_client_op_types.add(client_result.type)
- if client_result.type == cygrpc.OperationType.receive_initial_metadata:
+ self.assertNotIn(client_result.type(), found_client_op_types)
+ found_client_op_types.add(client_result.type())
+ if client_result.type(
+ ) == cygrpc.OperationType.receive_initial_metadata:
self.assertTrue(
test_common.metadata_transmitted(
server_initial_metadata,
- client_result.received_metadata))
- elif client_result.type == cygrpc.OperationType.receive_message:
- self.assertEqual(RESPONSE,
- client_result.received_message.bytes())
- elif client_result.type == cygrpc.OperationType.receive_status_on_client:
+ client_result.initial_metadata()))
+ elif client_result.type() == cygrpc.OperationType.receive_message:
+ self.assertEqual(RESPONSE, client_result.message())
+ elif client_result.type(
+ ) == cygrpc.OperationType.receive_status_on_client:
self.assertTrue(
test_common.metadata_transmitted(
server_trailing_metadata,
- client_result.received_metadata))
- self.assertEqual(SERVER_STATUS_DETAILS,
- client_result.received_status_details)
- self.assertEqual(SERVER_STATUS_CODE,
- client_result.received_status_code)
+ client_result.trailing_metadata()))
+ self.assertEqual(SERVER_STATUS_DETAILS, client_result.details())
+ self.assertEqual(SERVER_STATUS_CODE, client_result.code())
self.assertEqual(
set([
cygrpc.OperationType.send_initial_metadata,
@@ -281,13 +286,13 @@ class ServerClientMixin(object):
self.assertEqual(5, len(server_event.batch_operations))
found_server_op_types = set()
for server_result in server_event.batch_operations:
- self.assertNotIn(client_result.type, found_server_op_types)
- found_server_op_types.add(server_result.type)
- if server_result.type == cygrpc.OperationType.receive_message:
- self.assertEqual(REQUEST,
- server_result.received_message.bytes())
- elif server_result.type == cygrpc.OperationType.receive_close_on_server:
- self.assertFalse(server_result.received_cancelled)
+ self.assertNotIn(client_result.type(), found_server_op_types)
+ found_server_op_types.add(server_result.type())
+ if server_result.type() == cygrpc.OperationType.receive_message:
+ self.assertEqual(REQUEST, server_result.message())
+ elif server_result.type(
+ ) == cygrpc.OperationType.receive_close_on_server:
+ self.assertFalse(server_result.cancelled())
self.assertEqual(
set([
cygrpc.OperationType.send_initial_metadata,
@@ -323,13 +328,12 @@ class ServerClientMixin(object):
cygrpc_deadline, description)
client_event_future = perform_client_operations([
- cygrpc.operation_send_initial_metadata(empty_metadata,
- _EMPTY_FLAGS),
- cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),
+ cygrpc.SendInitialMetadataOperation(empty_metadata, _EMPTY_FLAGS),
+ cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),
], "Client prologue")
request_event = self.server_completion_queue.poll(cygrpc_deadline)
- server_call = request_event.operation_call
+ server_call = request_event.call
def perform_server_operations(operations, description):
return self._perform_operations(operations, server_call,
@@ -337,8 +341,7 @@ class ServerClientMixin(object):
cygrpc_deadline, description)
server_event_future = perform_server_operations([
- cygrpc.operation_send_initial_metadata(empty_metadata,
- _EMPTY_FLAGS),
+ cygrpc.SendInitialMetadataOperation(empty_metadata, _EMPTY_FLAGS),
], "Server prologue")
client_event_future.result() # force completion
@@ -347,12 +350,12 @@ class ServerClientMixin(object):
# Messaging
for _ in range(10):
client_event_future = perform_client_operations([
- cygrpc.operation_send_message(b'', _EMPTY_FLAGS),
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(b'', _EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
], "Client message")
server_event_future = perform_server_operations([
- cygrpc.operation_send_message(b'', _EMPTY_FLAGS),
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(b'', _EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
], "Server receive")
client_event_future.result() # force completion
@@ -360,13 +363,13 @@ class ServerClientMixin(object):
# Epilogue
client_event_future = perform_client_operations([
- cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS)
+ cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS)
], "Client epilogue")
server_event_future = perform_server_operations([
- cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
+ cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
empty_metadata, cygrpc.StatusCode.ok, b'', _EMPTY_FLAGS)
], "Server epilogue")
@@ -386,10 +389,11 @@ class InsecureServerInsecureClient(unittest.TestCase, ServerClientMixin):
class SecureServerSecureClient(unittest.TestCase, ServerClientMixin):
def setUp(self):
- server_credentials = cygrpc.server_credentials_ssl(None, [
- cygrpc.SslPemKeyCertPair(resources.private_key(),
- resources.certificate_chain())
- ], False)
+ server_credentials = cygrpc.server_credentials_ssl(
+ None, [
+ cygrpc.SslPemKeyCertPair(resources.private_key(),
+ resources.certificate_chain())
+ ], False)
client_credentials = cygrpc.SSLChannelCredentials(
resources.test_root_certificates(), None, None)
self.setUpMixin(server_credentials, client_credentials,
diff --git a/src/python/grpcio_tests/tests/unit/_empty_message_test.py b/src/python/grpcio_tests/tests/unit/_empty_message_test.py
index 14695bc13f..c55ef61c13 100644
--- a/src/python/grpcio_tests/tests/unit/_empty_message_test.py
+++ b/src/python/grpcio_tests/tests/unit/_empty_message_test.py
@@ -106,13 +106,13 @@ class EmptyMessageTest(unittest.TestCase):
list(response_iterator))
def testStreamUnary(self):
- response = self._channel.stream_unary(_STREAM_UNARY)(
- iter([_REQUEST] * test_constants.STREAM_LENGTH))
+ response = self._channel.stream_unary(_STREAM_UNARY)(iter(
+ [_REQUEST] * test_constants.STREAM_LENGTH))
self.assertEqual(_RESPONSE, response)
def testStreamStream(self):
- response_iterator = self._channel.stream_stream(_STREAM_STREAM)(
- iter([_REQUEST] * test_constants.STREAM_LENGTH))
+ response_iterator = self._channel.stream_stream(_STREAM_STREAM)(iter(
+ [_REQUEST] * test_constants.STREAM_LENGTH))
self.assertSequenceEqual([_RESPONSE] * test_constants.STREAM_LENGTH,
list(response_iterator))
diff --git a/src/python/grpcio_tests/tests/unit/_interceptor_test.py b/src/python/grpcio_tests/tests/unit/_interceptor_test.py
index 2aee298df2..3d547b71cd 100644
--- a/src/python/grpcio_tests/tests/unit/_interceptor_test.py
+++ b/src/python/grpcio_tests/tests/unit/_interceptor_test.py
@@ -65,7 +65,10 @@ class _Handler(object):
def handle_unary_unary(self, request, servicer_context):
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
return request
def handle_unary_stream(self, request, servicer_context):
@@ -74,7 +77,10 @@ class _Handler(object):
yield request
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
def handle_stream_unary(self, request_iterator, servicer_context):
if servicer_context is not None:
@@ -86,13 +92,19 @@ class _Handler(object):
response_elements.append(request)
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
return b''.join(response_elements)
def handle_stream_stream(self, request_iterator, servicer_context):
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
for request in request_iterator:
self._control.control()
yield request
@@ -162,9 +174,10 @@ def _stream_stream_multi_callable(channel):
class _ClientCallDetails(
- collections.namedtuple('_ClientCallDetails',
- ('method', 'timeout', 'metadata',
- 'credentials')), grpc.ClientCallDetails):
+ collections.namedtuple(
+ '_ClientCallDetails',
+ ('method', 'timeout', 'metadata', 'credentials')),
+ grpc.ClientCallDetails):
pass
@@ -262,7 +275,10 @@ def _append_request_header_interceptor(header, value):
metadata = []
if client_call_details.metadata:
metadata = list(client_call_details.metadata)
- metadata.append((header, value,))
+ metadata.append((
+ header,
+ value,
+ ))
client_call_details = _ClientCallDetails(
client_call_details.method, client_call_details.timeout, metadata,
client_call_details.credentials)
@@ -306,9 +322,11 @@ class InterceptorTest(unittest.TestCase):
self._server = grpc.server(
self._server_pool,
options=(('grpc.so_reuseport', 0),),
- interceptors=(_LoggingInterceptor('s1', self._record),
- conditional_interceptor,
- _LoggingInterceptor('s2', self._record),))
+ interceptors=(
+ _LoggingInterceptor('s1', self._record),
+ conditional_interceptor,
+ _LoggingInterceptor('s2', self._record),
+ ))
port = self._server.add_insecure_port('[::]:0')
self._server.add_generic_rpc_handlers((_GenericHandler(self._handler),))
self._server.start()
@@ -333,8 +351,8 @@ class InterceptorTest(unittest.TestCase):
interceptor = _wrap_request_iterator_stream_interceptor(triple)
channel = grpc.intercept_channel(self._channel, interceptor)
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
multi_callable = _stream_stream_multi_callable(channel)
response_iterator = multi_callable(
@@ -365,8 +383,8 @@ class InterceptorTest(unittest.TestCase):
multi_callable = _unary_unary_multi_callable(defective_channel)
call_future = multi_callable.future(
request,
- metadata=(
- ('test', 'InterceptedUnaryRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'InterceptedUnaryRequestBlockingUnaryResponse'),))
self.assertIsNotNone(call_future.exception())
self.assertEqual(call_future.code(), grpc.StatusCode.INTERNAL)
@@ -374,12 +392,14 @@ class InterceptorTest(unittest.TestCase):
def testInterceptedHeaderManipulationWithServerSideVerification(self):
request = b'\x07\x08'
- channel = grpc.intercept_channel(
- self._channel, _append_request_header_interceptor('secret', '42'))
- channel = grpc.intercept_channel(
- channel,
- _LoggingInterceptor('c1', self._record),
- _LoggingInterceptor('c2', self._record))
+ channel = grpc.intercept_channel(self._channel,
+ _append_request_header_interceptor(
+ 'secret', '42'))
+ channel = grpc.intercept_channel(channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
self._record[:] = []
@@ -401,16 +421,17 @@ class InterceptorTest(unittest.TestCase):
self._record[:] = []
- channel = grpc.intercept_channel(
- self._channel,
- _LoggingInterceptor('c1', self._record),
- _LoggingInterceptor('c2', self._record))
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
multi_callable = _unary_unary_multi_callable(channel)
multi_callable(
request,
- metadata=(
- ('test', 'InterceptedUnaryRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'InterceptedUnaryRequestBlockingUnaryResponse'),))
self.assertSequenceEqual(self._record, [
'c1:intercept_unary_unary', 'c2:intercept_unary_unary',
@@ -420,10 +441,11 @@ class InterceptorTest(unittest.TestCase):
def testInterceptedUnaryRequestBlockingUnaryResponseWithCall(self):
request = b'\x07\x08'
- channel = grpc.intercept_channel(
- self._channel,
- _LoggingInterceptor('c1', self._record),
- _LoggingInterceptor('c2', self._record))
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
self._record[:] = []
@@ -443,10 +465,11 @@ class InterceptorTest(unittest.TestCase):
request = b'\x07\x08'
self._record[:] = []
- channel = grpc.intercept_channel(
- self._channel,
- _LoggingInterceptor('c1', self._record),
- _LoggingInterceptor('c2', self._record))
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
multi_callable = _unary_unary_multi_callable(channel)
response_future = multi_callable.future(
@@ -463,10 +486,11 @@ class InterceptorTest(unittest.TestCase):
request = b'\x37\x58'
self._record[:] = []
- channel = grpc.intercept_channel(
- self._channel,
- _LoggingInterceptor('c1', self._record),
- _LoggingInterceptor('c2', self._record))
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
multi_callable = _unary_stream_multi_callable(channel)
response_iterator = multi_callable(
@@ -480,21 +504,22 @@ class InterceptorTest(unittest.TestCase):
])
def testInterceptedStreamRequestBlockingUnaryResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
self._record[:] = []
- channel = grpc.intercept_channel(
- self._channel,
- _LoggingInterceptor('c1', self._record),
- _LoggingInterceptor('c2', self._record))
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
multi_callable = _stream_unary_multi_callable(channel)
multi_callable(
request_iterator,
- metadata=(
- ('test', 'InterceptedStreamRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'InterceptedStreamRequestBlockingUnaryResponse'),))
self.assertSequenceEqual(self._record, [
'c1:intercept_stream_unary', 'c2:intercept_stream_unary',
@@ -502,15 +527,16 @@ class InterceptorTest(unittest.TestCase):
])
def testInterceptedStreamRequestBlockingUnaryResponseWithCall(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
self._record[:] = []
- channel = grpc.intercept_channel(
- self._channel,
- _LoggingInterceptor('c1', self._record),
- _LoggingInterceptor('c2', self._record))
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
multi_callable = _stream_unary_multi_callable(channel)
multi_callable.with_call(
@@ -525,15 +551,16 @@ class InterceptorTest(unittest.TestCase):
])
def testInterceptedStreamRequestFutureUnaryResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
self._record[:] = []
- channel = grpc.intercept_channel(
- self._channel,
- _LoggingInterceptor('c1', self._record),
- _LoggingInterceptor('c2', self._record))
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
multi_callable = _stream_unary_multi_callable(channel)
response_future = multi_callable.future(
@@ -547,15 +574,16 @@ class InterceptorTest(unittest.TestCase):
])
def testInterceptedStreamRequestStreamResponse(self):
- requests = tuple(b'\x77\x58'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x77\x58' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
self._record[:] = []
- channel = grpc.intercept_channel(
- self._channel,
- _LoggingInterceptor('c1', self._record),
- _LoggingInterceptor('c2', self._record))
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
multi_callable = _stream_stream_multi_callable(channel)
response_iterator = multi_callable(
diff --git a/src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py b/src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py
index 8f4c075e2c..4edf0fc4ad 100644
--- a/src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py
+++ b/src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py
@@ -106,8 +106,8 @@ class InvalidMetadataTest(unittest.TestCase):
self.assertEqual(response_iterator.code(), grpc.StatusCode.INTERNAL)
def testStreamRequestBlockingUnaryResponse(self):
- request_iterator = (b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = (
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
metadata = (('InVaLiD', 'StreamRequestBlockingUnaryResponse'),)
expected_error_details = "metadata was invalid: %s" % metadata
with self.assertRaises(ValueError) as exception_context:
@@ -115,8 +115,8 @@ class InvalidMetadataTest(unittest.TestCase):
self.assertIn(expected_error_details, str(exception_context.exception))
def testStreamRequestBlockingUnaryResponseWithCall(self):
- request_iterator = (b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = (
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
metadata = (('InVaLiD', 'StreamRequestBlockingUnaryResponseWithCall'),)
expected_error_details = "metadata was invalid: %s" % metadata
multi_callable = _stream_unary_multi_callable(self._channel)
@@ -125,8 +125,8 @@ class InvalidMetadataTest(unittest.TestCase):
self.assertIn(expected_error_details, str(exception_context.exception))
def testStreamRequestFutureUnaryResponse(self):
- request_iterator = (b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = (
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
metadata = (('InVaLiD', 'StreamRequestFutureUnaryResponse'),)
expected_error_details = "metadata was invalid: %s" % metadata
response_future = self._stream_unary.future(
@@ -141,8 +141,8 @@ class InvalidMetadataTest(unittest.TestCase):
self.assertEqual(response_future.code(), grpc.StatusCode.INTERNAL)
def testStreamRequestStreamResponse(self):
- request_iterator = (b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = (
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
metadata = (('InVaLiD', 'StreamRequestStreamResponse'),)
expected_error_details = "metadata was invalid: %s" % metadata
response_iterator = self._stream_stream(
diff --git a/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py b/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py
index b46d176d04..e40cca8b24 100644
--- a/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py
+++ b/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py
@@ -62,7 +62,10 @@ class _Handler(object):
def handle_unary_unary(self, request, servicer_context):
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
return request
def handle_unary_stream(self, request, servicer_context):
@@ -71,7 +74,10 @@ class _Handler(object):
yield request
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
def handle_stream_unary(self, request_iterator, servicer_context):
if servicer_context is not None:
@@ -83,13 +89,19 @@ class _Handler(object):
response_elements.append(request)
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
return b''.join(response_elements)
def handle_stream_stream(self, request_iterator, servicer_context):
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
for request in request_iterator:
self._control.control()
yield request
@@ -208,8 +220,8 @@ class InvocationDefectsTest(unittest.TestCase):
with self.assertRaises(grpc.RpcError):
response = multi_callable(
requests,
- metadata=(
- ('test', 'IterableStreamRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'IterableStreamRequestBlockingUnaryResponse'),))
def testIterableStreamRequestFutureUnaryResponse(self):
requests = [b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH)]
diff --git a/src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py b/src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py
index ec67f99fbc..bb6ac70497 100644
--- a/src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py
+++ b/src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py
@@ -36,16 +36,16 @@ _UNARY_STREAM = 'UnaryStream'
_STREAM_UNARY = 'StreamUnary'
_STREAM_STREAM = 'StreamStream'
-_CLIENT_METADATA = (('client-md-key', 'client-md-key'),
- ('client-md-key-bin', b'\x00\x01'))
+_CLIENT_METADATA = (('client-md-key', 'client-md-key'), ('client-md-key-bin',
+ b'\x00\x01'))
-_SERVER_INITIAL_METADATA = (
- ('server-initial-md-key', 'server-initial-md-value'),
- ('server-initial-md-key-bin', b'\x00\x02'))
+_SERVER_INITIAL_METADATA = (('server-initial-md-key',
+ 'server-initial-md-value'),
+ ('server-initial-md-key-bin', b'\x00\x02'))
-_SERVER_TRAILING_METADATA = (
- ('server-trailing-md-key', 'server-trailing-md-value'),
- ('server-trailing-md-key-bin', b'\x00\x03'))
+_SERVER_TRAILING_METADATA = (('server-trailing-md-key',
+ 'server-trailing-md-value'),
+ ('server-trailing-md-key-bin', b'\x00\x03'))
_NON_OK_CODE = grpc.StatusCode.NOT_FOUND
_DETAILS = 'Test details!'
@@ -193,17 +193,33 @@ class MetadataCodeDetailsTest(unittest.TestCase):
channel = grpc.insecure_channel('localhost:{}'.format(port))
self._unary_unary = channel.unary_unary(
- '/'.join(('', _SERVICE, _UNARY_UNARY,)),
+ '/'.join((
+ '',
+ _SERVICE,
+ _UNARY_UNARY,
+ )),
request_serializer=_REQUEST_SERIALIZER,
- response_deserializer=_RESPONSE_DESERIALIZER,)
- self._unary_stream = channel.unary_stream(
- '/'.join(('', _SERVICE, _UNARY_STREAM,)),)
- self._stream_unary = channel.stream_unary(
- '/'.join(('', _SERVICE, _STREAM_UNARY,)),)
+ response_deserializer=_RESPONSE_DESERIALIZER,
+ )
+ self._unary_stream = channel.unary_stream('/'.join((
+ '',
+ _SERVICE,
+ _UNARY_STREAM,
+ )),)
+ self._stream_unary = channel.stream_unary('/'.join((
+ '',
+ _SERVICE,
+ _STREAM_UNARY,
+ )),)
self._stream_stream = channel.stream_stream(
- '/'.join(('', _SERVICE, _STREAM_STREAM,)),
+ '/'.join((
+ '',
+ _SERVICE,
+ _STREAM_STREAM,
+ )),
request_serializer=_REQUEST_SERIALIZER,
- response_deserializer=_RESPONSE_DESERIALIZER,)
+ response_deserializer=_RESPONSE_DESERIALIZER,
+ )
def testSuccessfulUnaryUnary(self):
self._servicer.set_details(_DETAILS)
diff --git a/src/python/grpcio_tests/tests/unit/_metadata_test.py b/src/python/grpcio_tests/tests/unit/_metadata_test.py
index f2dac7bdc5..a918066ea4 100644
--- a/src/python/grpcio_tests/tests/unit/_metadata_test.py
+++ b/src/python/grpcio_tests/tests/unit/_metadata_test.py
@@ -33,18 +33,50 @@ _UNARY_STREAM = '/test/UnaryStream'
_STREAM_UNARY = '/test/StreamUnary'
_STREAM_STREAM = '/test/StreamStream'
-_INVOCATION_METADATA = ((b'invocation-md-key', u'invocation-md-value',),
- (u'invocation-md-key-bin', b'\x00\x01',),)
-_EXPECTED_INVOCATION_METADATA = (('invocation-md-key', 'invocation-md-value',),
- ('invocation-md-key-bin', b'\x00\x01',),)
+_INVOCATION_METADATA = (
+ (
+ b'invocation-md-key',
+ u'invocation-md-value',
+ ),
+ (
+ u'invocation-md-key-bin',
+ b'\x00\x01',
+ ),
+)
+_EXPECTED_INVOCATION_METADATA = (
+ (
+ 'invocation-md-key',
+ 'invocation-md-value',
+ ),
+ (
+ 'invocation-md-key-bin',
+ b'\x00\x01',
+ ),
+)
_INITIAL_METADATA = ((b'initial-md-key', u'initial-md-value'),
(u'initial-md-key-bin', b'\x00\x02'))
-_EXPECTED_INITIAL_METADATA = (('initial-md-key', 'initial-md-value',),
- ('initial-md-key-bin', b'\x00\x02',),)
-
-_TRAILING_METADATA = (('server-trailing-md-key', 'server-trailing-md-value',),
- ('server-trailing-md-key-bin', b'\x00\x03',),)
+_EXPECTED_INITIAL_METADATA = (
+ (
+ 'initial-md-key',
+ 'initial-md-value',
+ ),
+ (
+ 'initial-md-key-bin',
+ b'\x00\x02',
+ ),
+)
+
+_TRAILING_METADATA = (
+ (
+ 'server-trailing-md-key',
+ 'server-trailing-md-value',
+ ),
+ (
+ 'server-trailing-md-key-bin',
+ b'\x00\x03',
+ ),
+)
_EXPECTED_TRAILING_METADATA = _TRAILING_METADATA
@@ -146,8 +178,8 @@ class MetadataTest(unittest.TestCase):
def setUp(self):
self._server = test_common.test_server()
- self._server.add_generic_rpc_handlers(
- (_GenericHandler(weakref.proxy(self)),))
+ self._server.add_generic_rpc_handlers((_GenericHandler(
+ weakref.proxy(self)),))
port = self._server.add_insecure_port('[::]:0')
self._server.start()
self._channel = grpc.insecure_channel(
diff --git a/src/python/grpcio_tests/tests/unit/_rpc_test.py b/src/python/grpcio_tests/tests/unit/_rpc_test.py
index 1515a87d93..54f01d9f8d 100644
--- a/src/python/grpcio_tests/tests/unit/_rpc_test.py
+++ b/src/python/grpcio_tests/tests/unit/_rpc_test.py
@@ -64,7 +64,10 @@ class _Handler(object):
def handle_unary_unary(self, request, servicer_context):
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
# TODO(https://github.com/grpc/grpc/issues/8483): test the values
# returned by these methods rather than only "smoke" testing that
# the return after having been called.
@@ -78,7 +81,10 @@ class _Handler(object):
yield request
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
def handle_stream_unary(self, request_iterator, servicer_context):
if servicer_context is not None:
@@ -90,13 +96,19 @@ class _Handler(object):
response_elements.append(request)
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
return b''.join(response_elements)
def handle_stream_stream(self, request_iterator, servicer_context):
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
for request in request_iterator:
self._control.control()
yield request
@@ -244,8 +256,8 @@ class RPCTest(unittest.TestCase):
self.assertSequenceEqual(expected_responses, responses)
def testSuccessfulStreamRequestBlockingUnaryResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
expected_response = self._handler.handle_stream_unary(
iter(requests), None)
request_iterator = iter(requests)
@@ -253,14 +265,14 @@ class RPCTest(unittest.TestCase):
multi_callable = _stream_unary_multi_callable(self._channel)
response = multi_callable(
request_iterator,
- metadata=(
- ('test', 'SuccessfulStreamRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'SuccessfulStreamRequestBlockingUnaryResponse'),))
self.assertEqual(expected_response, response)
def testSuccessfulStreamRequestBlockingUnaryResponseWithCall(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
expected_response = self._handler.handle_stream_unary(
iter(requests), None)
request_iterator = iter(requests)
@@ -276,8 +288,8 @@ class RPCTest(unittest.TestCase):
self.assertIs(grpc.StatusCode.OK, call.code())
def testSuccessfulStreamRequestFutureUnaryResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
expected_response = self._handler.handle_stream_unary(
iter(requests), None)
request_iterator = iter(requests)
@@ -293,8 +305,8 @@ class RPCTest(unittest.TestCase):
self.assertIsNone(response_future.traceback())
def testSuccessfulStreamRequestStreamResponse(self):
- requests = tuple(b'\x77\x58'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x77\x58' for _ in range(test_constants.STREAM_LENGTH))
expected_responses = tuple(
self._handler.handle_stream_stream(iter(requests), None))
request_iterator = iter(requests)
@@ -326,8 +338,8 @@ class RPCTest(unittest.TestCase):
def testConcurrentBlockingInvocations(self):
pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
expected_response = self._handler.handle_stream_unary(
iter(requests), None)
expected_responses = [expected_response
@@ -342,15 +354,15 @@ class RPCTest(unittest.TestCase):
request_iterator,
metadata=(('test', 'ConcurrentBlockingInvocations'),))
response_futures[index] = response_future
- responses = tuple(response_future.result()
- for response_future in response_futures)
+ responses = tuple(
+ response_future.result() for response_future in response_futures)
pool.shutdown(wait=True)
self.assertSequenceEqual(expected_responses, responses)
def testConcurrentFutureInvocations(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
expected_response = self._handler.handle_stream_unary(
iter(requests), None)
expected_responses = [expected_response
@@ -364,8 +376,8 @@ class RPCTest(unittest.TestCase):
request_iterator,
metadata=(('test', 'ConcurrentFutureInvocations'),))
response_futures[index] = response_future
- responses = tuple(response_future.result()
- for response_future in response_futures)
+ responses = tuple(
+ response_future.result() for response_future in response_futures)
self.assertSequenceEqual(expected_responses, responses)
@@ -424,14 +436,14 @@ class RPCTest(unittest.TestCase):
multi_callable = _unary_stream_multi_callable(self._channel)
response_iterator = multi_callable(
request,
- metadata=(
- ('test', 'ConsumingSomeButNotAllStreamResponsesUnaryRequest'),))
+ metadata=(('test',
+ 'ConsumingSomeButNotAllStreamResponsesUnaryRequest'),))
for _ in range(test_constants.STREAM_LENGTH // 2):
next(response_iterator)
def testConsumingSomeButNotAllStreamResponsesStreamRequest(self):
- requests = tuple(b'\x67\x88'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x67\x88' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
@@ -443,15 +455,15 @@ class RPCTest(unittest.TestCase):
next(response_iterator)
def testConsumingTooManyStreamResponsesStreamRequest(self):
- requests = tuple(b'\x67\x88'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x67\x88' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
response_iterator = multi_callable(
request_iterator,
- metadata=(
- ('test', 'ConsumingTooManyStreamResponsesStreamRequest'),))
+ metadata=(('test',
+ 'ConsumingTooManyStreamResponsesStreamRequest'),))
for _ in range(test_constants.STREAM_LENGTH):
next(response_iterator)
for _ in range(test_constants.STREAM_LENGTH):
@@ -503,8 +515,8 @@ class RPCTest(unittest.TestCase):
self.assertIsNotNone(response_iterator.trailing_metadata())
def testCancelledStreamRequestUnaryResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_unary_multi_callable(self._channel)
@@ -528,8 +540,8 @@ class RPCTest(unittest.TestCase):
self.assertIsNotNone(response_future.trailing_metadata())
def testCancelledStreamRequestStreamResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
@@ -555,8 +567,8 @@ class RPCTest(unittest.TestCase):
multi_callable.with_call(
request,
timeout=test_constants.SHORT_TIMEOUT,
- metadata=(
- ('test', 'ExpiredUnaryRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'ExpiredUnaryRequestBlockingUnaryResponse'),))
self.assertIsInstance(exception_context.exception, grpc.Call)
self.assertIsNotNone(exception_context.exception.initial_metadata())
@@ -610,8 +622,8 @@ class RPCTest(unittest.TestCase):
response_iterator.code())
def testExpiredStreamRequestBlockingUnaryResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_unary_multi_callable(self._channel)
@@ -620,8 +632,8 @@ class RPCTest(unittest.TestCase):
multi_callable(
request_iterator,
timeout=test_constants.SHORT_TIMEOUT,
- metadata=(
- ('test', 'ExpiredStreamRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'ExpiredStreamRequestBlockingUnaryResponse'),))
self.assertIsInstance(exception_context.exception, grpc.RpcError)
self.assertIsInstance(exception_context.exception, grpc.Call)
@@ -632,8 +644,8 @@ class RPCTest(unittest.TestCase):
self.assertIsNotNone(exception_context.exception.trailing_metadata())
def testExpiredStreamRequestFutureUnaryResponse(self):
- requests = tuple(b'\x07\x18'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x18' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
callback = _Callback()
@@ -644,8 +656,8 @@ class RPCTest(unittest.TestCase):
timeout=test_constants.SHORT_TIMEOUT,
metadata=(('test', 'ExpiredStreamRequestFutureUnaryResponse'),))
with self.assertRaises(grpc.FutureTimeoutError):
- response_future.result(timeout=test_constants.SHORT_TIMEOUT /
- 2.0)
+ response_future.result(
+ timeout=test_constants.SHORT_TIMEOUT / 2.0)
response_future.add_done_callback(callback)
value_passed_to_callback = callback.value()
@@ -663,8 +675,8 @@ class RPCTest(unittest.TestCase):
self.assertIsNotNone(response_future.trailing_metadata())
def testExpiredStreamRequestStreamResponse(self):
- requests = tuple(b'\x67\x18'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x67\x18' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
@@ -689,8 +701,8 @@ class RPCTest(unittest.TestCase):
with self.assertRaises(grpc.RpcError) as exception_context:
multi_callable.with_call(
request,
- metadata=(
- ('test', 'FailedUnaryRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'FailedUnaryRequestBlockingUnaryResponse'),))
self.assertIs(grpc.StatusCode.UNKNOWN,
exception_context.exception.code())
@@ -734,8 +746,8 @@ class RPCTest(unittest.TestCase):
exception_context.exception.code())
def testFailedStreamRequestBlockingUnaryResponse(self):
- requests = tuple(b'\x47\x58'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x47\x58' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_unary_multi_callable(self._channel)
@@ -743,15 +755,15 @@ class RPCTest(unittest.TestCase):
with self.assertRaises(grpc.RpcError) as exception_context:
multi_callable(
request_iterator,
- metadata=(
- ('test', 'FailedStreamRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'FailedStreamRequestBlockingUnaryResponse'),))
self.assertIs(grpc.StatusCode.UNKNOWN,
exception_context.exception.code())
def testFailedStreamRequestFutureUnaryResponse(self):
- requests = tuple(b'\x07\x18'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x18' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
callback = _Callback()
@@ -773,8 +785,8 @@ class RPCTest(unittest.TestCase):
self.assertIs(response_future, value_passed_to_callback)
def testFailedStreamRequestStreamResponse(self):
- requests = tuple(b'\x67\x88'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x67\x88' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
@@ -805,8 +817,8 @@ class RPCTest(unittest.TestCase):
request, metadata=(('test', 'IgnoredUnaryRequestStreamResponse'),))
def testIgnoredStreamRequestFutureUnaryResponse(self):
- requests = tuple(b'\x07\x18'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x18' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_unary_multi_callable(self._channel)
@@ -815,8 +827,8 @@ class RPCTest(unittest.TestCase):
metadata=(('test', 'IgnoredStreamRequestFutureUnaryResponse'),))
def testIgnoredStreamRequestStreamResponse(self):
- requests = tuple(b'\x67\x88'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x67\x88' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
diff --git a/src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py b/src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py
index 2c513da5d0..0d78034b7b 100644
--- a/src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py
+++ b/src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py
@@ -74,7 +74,8 @@ def _create_client_stub(
expect_success,
root_certificates=None,
private_key=None,
- certificate_chain=None,):
+ certificate_chain=None,
+):
channel = grpc.secure_channel('localhost:{}'.format(port),
grpc.ssl_channel_credentials(
root_certificates=root_certificates,
diff --git a/src/python/grpcio_tests/tests/unit/_thread_cleanup_test.py b/src/python/grpcio_tests/tests/unit/_thread_cleanup_test.py
index fe3e71d686..18f5af058a 100644
--- a/src/python/grpcio_tests/tests/unit/_thread_cleanup_test.py
+++ b/src/python/grpcio_tests/tests/unit/_thread_cleanup_test.py
@@ -52,7 +52,9 @@ class CleanupThreadTest(unittest.TestCase):
target=target,
name='test-name',
args=('arg1', 'arg2'),
- kwargs={'arg3': 'arg3'})
+ kwargs={
+ 'arg3': 'arg3'
+ })
cleanup_thread.start()
cleanup_thread.join()
self.assertEqual(cleanup_thread.name, 'test-name')
diff --git a/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py b/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py
index eb8dc80a6e..61c03f64ba 100644
--- a/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py
+++ b/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py
@@ -163,7 +163,10 @@ class BetaFeaturesTest(unittest.TestCase):
self._server = implementations.server(
method_implementations, options=server_options)
server_credentials = implementations.ssl_server_credentials([
- (resources.private_key(), resources.certificate_chain(),),
+ (
+ resources.private_key(),
+ resources.certificate_chain(),
+ ),
])
port = self._server.add_secure_port('[::]:0', server_credentials)
self._server.start()
@@ -289,7 +292,10 @@ class ContextManagementAndLifecycleTest(unittest.TestCase):
self._server_options = implementations.server_options(
thread_pool_size=test_constants.POOL_SIZE)
self._server_credentials = implementations.ssl_server_credentials([
- (resources.private_key(), resources.certificate_chain(),),
+ (
+ resources.private_key(),
+ resources.certificate_chain(),
+ ),
])
self._channel_credentials = implementations.ssl_channel_credentials(
resources.test_root_certificates())
diff --git a/src/python/grpcio_tests/tests/unit/beta/_face_interface_test.py b/src/python/grpcio_tests/tests/unit/beta/_face_interface_test.py
index e4b81e7e78..c99738e085 100644
--- a/src/python/grpcio_tests/tests/unit/beta/_face_interface_test.py
+++ b/src/python/grpcio_tests/tests/unit/beta/_face_interface_test.py
@@ -32,8 +32,11 @@ _SERVER_HOST_OVERRIDE = 'foo.test.google.fr'
class _SerializationBehaviors(
collections.namedtuple('_SerializationBehaviors', (
- 'request_serializers', 'request_deserializers',
- 'response_serializers', 'response_deserializers',))):
+ 'request_serializers',
+ 'request_deserializers',
+ 'response_serializers',
+ 'response_deserializers',
+ ))):
pass
@@ -73,7 +76,10 @@ class _Implementation(test_interfaces.Implementation):
server = implementations.server(
method_implementations, options=server_options)
server_credentials = implementations.ssl_server_credentials([
- (resources.private_key(), resources.certificate_chain(),),
+ (
+ resources.private_key(),
+ resources.certificate_chain(),
+ ),
])
port = server.add_secure_port('[::]:0', server_credentials)
server.start()
@@ -116,9 +122,10 @@ class _Implementation(test_interfaces.Implementation):
def load_tests(loader, tests, pattern):
- return unittest.TestSuite(tests=tuple(
- loader.loadTestsFromTestCase(test_case_class)
- for test_case_class in test_cases.test_cases(_Implementation())))
+ return unittest.TestSuite(
+ tests=tuple(
+ loader.loadTestsFromTestCase(test_case_class)
+ for test_case_class in test_cases.test_cases(_Implementation())))
if __name__ == '__main__':
diff --git a/src/python/grpcio_tests/tests/unit/beta/_implementations_test.py b/src/python/grpcio_tests/tests/unit/beta/_implementations_test.py
index 75a615eeff..5a53766d29 100644
--- a/src/python/grpcio_tests/tests/unit/beta/_implementations_test.py
+++ b/src/python/grpcio_tests/tests/unit/beta/_implementations_test.py
@@ -41,8 +41,8 @@ class CallCredentialsTest(unittest.TestCase):
def test_google_call_credentials(self):
creds = oauth2client_client.GoogleCredentials(
'token', 'client_id', 'secret', 'refresh_token',
- datetime.datetime(2008, 6, 24), 'https://refresh.uri.com/',
- 'user_agent')
+ datetime.datetime(2008, 6,
+ 24), 'https://refresh.uri.com/', 'user_agent')
call_creds = implementations.google_call_credentials(creds)
self.assertIsInstance(call_creds, implementations.CallCredentials)
diff --git a/src/python/grpcio_tests/tests/unit/beta/test_utilities.py b/src/python/grpcio_tests/tests/unit/beta/test_utilities.py
index 65da0f2020..c8d920d35e 100644
--- a/src/python/grpcio_tests/tests/unit/beta/test_utilities.py
+++ b/src/python/grpcio_tests/tests/unit/beta/test_utilities.py
@@ -33,6 +33,8 @@ def not_really_secure_channel(host, port, channel_credentials,
conducted.
"""
target = '%s:%d' % (host, port)
- channel = grpc.secure_channel(target, channel_credentials, (
- ('grpc.ssl_target_name_override', server_host_override,),))
+ channel = grpc.secure_channel(target, channel_credentials, ((
+ 'grpc.ssl_target_name_override',
+ server_host_override,
+ ),))
return implementations.Channel(channel)
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
index 45fd321ed6..5d8679aa62 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
@@ -70,8 +70,8 @@ class TestCase(
self.implementation.destantiate(self._memo)
def testSuccessfulUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -81,8 +81,8 @@ class TestCase(
test_messages.verify(request, response, self)
def testSuccessfulUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -93,8 +93,8 @@ class TestCase(
test_messages.verify(request, responses, self)
def testSuccessfulStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -104,8 +104,8 @@ class TestCase(
test_messages.verify(requests, response, self)
def testSuccessfulStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -116,8 +116,8 @@ class TestCase(
test_messages.verify(requests, responses, self)
def testSequentialInvocations(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -134,8 +134,8 @@ class TestCase(
def testParallelInvocations(self):
pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures = []
@@ -158,8 +158,8 @@ class TestCase(
def testWaitingForSomeButNotAllParallelInvocations(self):
pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures_to_indices = {}
@@ -197,8 +197,8 @@ class TestCase(
raise NotImplementedError()
def testExpiredUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -208,8 +208,8 @@ class TestCase(
request, _3069_test_constant.REALLY_SHORT_TIMEOUT)
def testExpiredUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -220,33 +220,33 @@ class TestCase(
list(response_iterator)
def testExpiredStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
with self._control.pause(), self.assertRaises(
face.ExpirationError):
- self._invoker.blocking(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ self._invoker.blocking(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
def testExpiredStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
with self._control.pause(), self.assertRaises(
face.ExpirationError):
- response_iterator = self._invoker.blocking(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ response_iterator = self._invoker.blocking(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
list(response_iterator)
def testFailedUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -255,8 +255,8 @@ class TestCase(
request, test_constants.LONG_TIMEOUT)
def testFailedUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -266,8 +266,8 @@ class TestCase(
list(response_iterator)
def testFailedStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -276,8 +276,8 @@ class TestCase(
iter(requests), test_constants.LONG_TIMEOUT)
def testFailedStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_digest.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_digest.py
index 0e399c4bc4..b1c33da43a 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_digest.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_digest.py
@@ -34,11 +34,15 @@ _IDENTITY = lambda x: x
class TestServiceDigest(
collections.namedtuple('TestServiceDigest', (
- 'methods', 'inline_method_implementations',
- 'event_method_implementations', 'multi_method_implementation',
- 'unary_unary_messages_sequences', 'unary_stream_messages_sequences',
+ 'methods',
+ 'inline_method_implementations',
+ 'event_method_implementations',
+ 'multi_method_implementation',
+ 'unary_unary_messages_sequences',
+ 'unary_stream_messages_sequences',
'stream_unary_messages_sequences',
- 'stream_stream_messages_sequences',))):
+ 'stream_stream_messages_sequences',
+ ))):
"""A transformation of a service.TestService.
Attributes:
@@ -421,8 +425,8 @@ def digest(service, control, pool):
events.update(stream_unary.events)
events.update(stream_stream.events)
- return TestServiceDigest(
- methods, inlines, events,
- _MultiMethodImplementation(adaptations, control, pool),
- unary_unary.messages, unary_stream.messages, stream_unary.messages,
- stream_stream.messages)
+ return TestServiceDigest(methods, inlines, events,
+ _MultiMethodImplementation(adaptations, control,
+ pool),
+ unary_unary.messages, unary_stream.messages,
+ stream_unary.messages, stream_stream.messages)
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
index bc65bf4c80..3d9b2816aa 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
@@ -134,8 +134,8 @@ class TestCase(
self._digest_pool.shutdown(wait=True)
def testSuccessfulUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -151,8 +151,8 @@ class TestCase(
self.assertIsNone(response_future.traceback())
def testSuccessfulUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -163,8 +163,8 @@ class TestCase(
test_messages.verify(request, responses, self)
def testSuccessfulStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@@ -185,8 +185,8 @@ class TestCase(
self.assertIsNone(response_future.traceback())
def testSuccessfulStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@@ -201,8 +201,8 @@ class TestCase(
test_messages.verify(requests, responses, self)
def testSequentialInvocations(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -220,8 +220,8 @@ class TestCase(
test_messages.verify(second_request, second_response, self)
def testParallelInvocations(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -236,8 +236,8 @@ class TestCase(
test_messages.verify(first_request, first_response, self)
test_messages.verify(second_request, second_response, self)
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures = []
@@ -258,8 +258,8 @@ class TestCase(
def testWaitingForSomeButNotAllParallelInvocations(self):
pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures_to_indices = {}
@@ -282,8 +282,8 @@ class TestCase(
pool.shutdown(wait=True)
def testCancelledUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -305,8 +305,8 @@ class TestCase(
response_future.traceback()
def testCancelledUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -319,8 +319,8 @@ class TestCase(
next(response_iterator)
def testCancelledStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
@@ -342,8 +342,8 @@ class TestCase(
response_future.traceback()
def testCancelledStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -356,8 +356,8 @@ class TestCase(
next(response_iterator)
def testExpiredUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -376,8 +376,8 @@ class TestCase(
self.assertIsNotNone(response_future.traceback())
def testExpiredUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -388,16 +388,16 @@ class TestCase(
list(response_iterator)
def testExpiredStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
with self._control.pause():
- response_future = self._invoker.future(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ response_future = self._invoker.future(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
response_future.add_done_callback(callback)
self.assertIs(callback.future(), response_future)
self.assertIsInstance(response_future.exception(),
@@ -409,21 +409,21 @@ class TestCase(
self.assertIsNotNone(response_future.traceback())
def testExpiredStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
with self._control.pause():
- response_iterator = self._invoker.future(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ response_iterator = self._invoker.future(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
with self.assertRaises(face.ExpirationError):
list(response_iterator)
def testFailedUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -448,8 +448,8 @@ class TestCase(
self.assertIsNotNone(abortion_callback.future())
def testFailedUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -464,17 +464,17 @@ class TestCase(
list(response_iterator)
def testFailedStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
abortion_callback = _Callback()
with self._control.fail():
- response_future = self._invoker.future(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ response_future = self._invoker.future(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
response_future.add_done_callback(callback)
response_future.add_abortion_callback(abortion_callback)
@@ -491,8 +491,8 @@ class TestCase(
self.assertIsNotNone(abortion_callback.future())
def testFailedStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -502,7 +502,7 @@ class TestCase(
# expiration of the RPC.
with self._control.fail(), self.assertRaises(
face.ExpirationError):
- response_iterator = self._invoker.future(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ response_iterator = self._invoker.future(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
list(response_iterator)
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_invocation.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_invocation.py
index fd55f4e09f..efc93d56b0 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_invocation.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_invocation.py
@@ -191,5 +191,8 @@ def invoker_constructors():
Returns:
A sequence of InvokerConstructors.
"""
- return (_GenericInvokerConstructor(), _MultiCallableInvokerConstructor(),
- _DynamicInvokerConstructor(),)
+ return (
+ _GenericInvokerConstructor(),
+ _MultiCallableInvokerConstructor(),
+ _DynamicInvokerConstructor(),
+ )
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_stock_service.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_stock_service.py
index 69c7ac2d73..a84e02a79a 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_stock_service.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_stock_service.py
@@ -33,8 +33,8 @@ def _get_last_trade_price(stock_request, stock_reply_callback, control, active):
if active():
stock_reply_callback(
stock_pb2.StockReply(
- symbol=stock_request.symbol, price=_price(
- stock_request.symbol)))
+ symbol=stock_request.symbol,
+ price=_price(stock_request.symbol)))
else:
raise abandonment.Abandoned()
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/test_cases.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/test_cases.py
index d1c5b8f76b..cff4b7cdea 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/test_cases.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/test_cases.py
@@ -24,7 +24,8 @@ from tests.unit.framework.interfaces.face import test_interfaces # pylint: disa
_TEST_CASE_SUPERCLASSES = (
_blocking_invocation_inline_service.TestCase,
- _future_invocation_asynchronous_event_service.TestCase,)
+ _future_invocation_asynchronous_event_service.TestCase,
+)
def test_cases(implementation):
@@ -42,8 +43,9 @@ def test_cases(implementation):
for invoker_constructor in _invocation.invoker_constructors():
for super_class in _TEST_CASE_SUPERCLASSES:
test_case_classes.append(
- type(invoker_constructor.name() + super_class.NAME, (
- super_class,), {
+ type(
+ invoker_constructor.name() + super_class.NAME,
+ (super_class,), {
'implementation': implementation,
'invoker_constructor': invoker_constructor,
'__module__': implementation.__module__,
diff --git a/src/python/grpcio_tests/tests/unit/resources.py b/src/python/grpcio_tests/tests/unit/resources.py
index 11ef9e8565..51a8979f58 100644
--- a/src/python/grpcio_tests/tests/unit/resources.py
+++ b/src/python/grpcio_tests/tests/unit/resources.py
@@ -58,7 +58,8 @@ def cert_hier_1_client_1_key():
def cert_hier_1_client_1_cert():
return pkg_resources.resource_string(
__name__,
- 'credentials/certificate_hierarchy_1/intermediate/certs/client.cert.pem')
+ 'credentials/certificate_hierarchy_1/intermediate/certs/client.cert.pem'
+ )
def cert_hier_1_server_1_key():
@@ -97,7 +98,8 @@ def cert_hier_2_client_1_key():
def cert_hier_2_client_1_cert():
return pkg_resources.resource_string(
__name__,
- 'credentials/certificate_hierarchy_2/intermediate/certs/client.cert.pem')
+ 'credentials/certificate_hierarchy_2/intermediate/certs/client.cert.pem'
+ )
def cert_hier_2_server_1_key():
diff --git a/src/python/grpcio_tests/tests/unit/test_common.py b/src/python/grpcio_tests/tests/unit/test_common.py
index 6334a32b0e..61717ae135 100644
--- a/src/python/grpcio_tests/tests/unit/test_common.py
+++ b/src/python/grpcio_tests/tests/unit/test_common.py
@@ -19,9 +19,21 @@ from concurrent import futures
import grpc
import six
-INVOCATION_INITIAL_METADATA = (('0', 'abc'), ('1', 'def'), ('2', 'ghi'),)
-SERVICE_INITIAL_METADATA = (('3', 'jkl'), ('4', 'mno'), ('5', 'pqr'),)
-SERVICE_TERMINAL_METADATA = (('6', 'stu'), ('7', 'vwx'), ('8', 'yza'),)
+INVOCATION_INITIAL_METADATA = (
+ ('0', 'abc'),
+ ('1', 'def'),
+ ('2', 'ghi'),
+)
+SERVICE_INITIAL_METADATA = (
+ ('3', 'jkl'),
+ ('4', 'mno'),
+ ('5', 'pqr'),
+)
+SERVICE_TERMINAL_METADATA = (
+ ('6', 'stu'),
+ ('7', 'vwx'),
+ ('8', 'yza'),
+)
DETAILS = 'test details'
@@ -80,8 +92,10 @@ def test_secure_channel(target, channel_credentials, server_host_override):
An implementations.Channel to the remote host through which RPCs may be
conducted.
"""
- channel = grpc.secure_channel(target, channel_credentials, (
- ('grpc.ssl_target_name_override', server_host_override,),))
+ channel = grpc.secure_channel(target, channel_credentials, ((
+ 'grpc.ssl_target_name_override',
+ server_host_override,
+ ),))
return channel