diff options
Diffstat (limited to 'src/python/grpcio_test')
-rw-r--r-- | src/python/grpcio_test/.gitignore | 2 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_cython/cygrpc_test.py | 22 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/test_common.py | 12 | ||||
-rw-r--r-- | src/python/grpcio_test/setup.cfg | 1 | ||||
-rw-r--r-- | src/python/grpcio_test/setup.py | 2 |
5 files changed, 23 insertions, 16 deletions
diff --git a/src/python/grpcio_test/.gitignore b/src/python/grpcio_test/.gitignore index e3540baa7c..4bb4d42dfe 100644 --- a/src/python/grpcio_test/.gitignore +++ b/src/python/grpcio_test/.gitignore @@ -7,5 +7,5 @@ dist/ *.eggs/ .coverage .coverage.* -.cache +.cache/ nosetests.xml diff --git a/src/python/grpcio_test/grpc_test/_cython/cygrpc_test.py b/src/python/grpcio_test/grpc_test/_cython/cygrpc_test.py index 637506b42e..1307a30ca0 100644 --- a/src/python/grpcio_test/grpc_test/_cython/cygrpc_test.py +++ b/src/python/grpcio_test/grpc_test/_cython/cygrpc_test.py @@ -32,6 +32,7 @@ import unittest from grpc._cython import cygrpc from grpc_test._cython import test_utilities +from grpc_test import test_common class TypeSmokeTest(unittest.TestCase): @@ -139,7 +140,7 @@ class InsecureServerInsecureClient(unittest.TestCase): CLIENT_METADATA_BIN_VALUE = b'\0'*1000 SERVER_INITIAL_METADATA_KEY = b'init_me_me_me' SERVER_INITIAL_METADATA_VALUE = b'whodawha?' - SERVER_TRAILING_METADATA_KEY = b'California_is_in_a_drought' + SERVER_TRAILING_METADATA_KEY = b'california_is_in_a_drought' SERVER_TRAILING_METADATA_VALUE = b'zomg it is' SERVER_STATUS_CODE = cygrpc.StatusCode.ok SERVER_STATUS_DETAILS = b'our work is never over' @@ -158,8 +159,8 @@ class InsecureServerInsecureClient(unittest.TestCase): self.assertEqual(cygrpc.CallError.ok, request_call_result) client_call_tag = object() - client_call = self.client_channel.create_call(self.client_completion_queue, - METHOD, HOST, cygrpc_deadline) + client_call = self.client_channel.create_call( + None, 0, self.client_completion_queue, METHOD, HOST, cygrpc_deadline) client_initial_metadata = cygrpc.Metadata([ cygrpc.Metadatum(CLIENT_METADATA_ASCII_KEY, CLIENT_METADATA_ASCII_VALUE), @@ -182,8 +183,9 @@ class InsecureServerInsecureClient(unittest.TestCase): self.assertIsInstance(request_event.operation_call, cygrpc.Call) self.assertIs(server_request_tag, request_event.tag) self.assertEqual(0, len(request_event.batch_operations)) - self.assertEqual(dict(client_initial_metadata), - dict(request_event.request_metadata)) + self.assertTrue( + test_common.metadata_transmitted(client_initial_metadata, + request_event.request_metadata)) self.assertEqual(METHOD, request_event.request_call_details.method) self.assertEqual(HOST, request_event.request_call_details.host) self.assertLess( @@ -218,13 +220,15 @@ class InsecureServerInsecureClient(unittest.TestCase): 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.assertEqual(dict(server_initial_metadata), - dict(client_result.received_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: - self.assertEqual(dict(server_trailing_metadata), - dict(client_result.received_metadata)) + 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) diff --git a/src/python/grpcio_test/grpc_test/test_common.py b/src/python/grpcio_test/grpc_test/test_common.py index 44284be88b..29431bfb9d 100644 --- a/src/python/grpcio_test/grpc_test/test_common.py +++ b/src/python/grpcio_test/grpc_test/test_common.py @@ -46,19 +46,23 @@ def metadata_transmitted(original_metadata, transmitted_metadata): the same key. Args: - original_metadata: A metadata value used in a test of gRPC. + original_metadata: A metadata value used in a test of gRPC. An iterable over + iterables of length 2. transmitted_metadata: A metadata value corresponding to original_metadata - after having been transmitted via gRPC. + after having been transmitted via gRPC. An iterable over iterables of + length 2. Returns: A boolean indicating whether transmitted_metadata accurately reflects original_metadata after having been transmitted via gRPC. """ original = collections.defaultdict(list) - for key, value in original_metadata: + for key_value_pair in original_metadata: + key, value = tuple(key_value_pair) original[key].append(value) transmitted = collections.defaultdict(list) - for key, value in transmitted_metadata: + for key_value_pair in transmitted_metadata: + key, value = tuple(key_value_pair) transmitted[key].append(value) for key, values in original.iteritems(): diff --git a/src/python/grpcio_test/setup.cfg b/src/python/grpcio_test/setup.cfg index b32d3f5972..3be93cb918 100644 --- a/src/python/grpcio_test/setup.cfg +++ b/src/python/grpcio_test/setup.cfg @@ -1,3 +1,2 @@ [pytest] -norecursedirs = _cython python_files = *_test.py diff --git a/src/python/grpcio_test/setup.py b/src/python/grpcio_test/setup.py index fe36bc9232..0f43b4a638 100644 --- a/src/python/grpcio_test/setup.py +++ b/src/python/grpcio_test/setup.py @@ -40,7 +40,7 @@ os.chdir(os.path.dirname(os.path.abspath(__file__))) # Break import-style to ensure we can actually find our commands module. import commands -_PACKAGES = setuptools.find_packages('.', exclude=['*._cython', '*._cython.*']) +_PACKAGES = setuptools.find_packages('.') _PACKAGE_DIRECTORIES = { '': '.', |