def testSequentialInvocations(self): # pylint: disable=cell-var-from-loop for name, test_messages_sequence in ( self.digest.unary_unary_messages_sequences.iteritems()): for test_messages in test_messages_sequence: first_request = test_messages.request() second_request = test_messages.request() first_callback = testing_callback.Callback() second_callback = testing_callback.Callback() def make_second_invocation(first_response): first_callback.complete(first_response) self.stub.event_value_in_value_out( name, second_request, second_callback.complete, second_callback.abort, test_constants.SHORT_TIMEOUT) self.stub.event_value_in_value_out( name, first_request, make_second_invocation, first_callback.abort, test_constants.SHORT_TIMEOUT) second_callback.block_until_terminated() first_response = first_callback.response() second_response = second_callback.response() test_messages.verify(first_request, first_response, self) test_messages.verify(second_request, second_response, self)
def testParallelInvocations(self): for name, test_messages_sequence in ( self.digest.unary_unary_messages_sequences.iteritems()): for test_messages in test_messages_sequence: first_request = test_messages.request() first_callback = testing_callback.Callback() second_request = test_messages.request() second_callback = testing_callback.Callback() self.stub.event_value_in_value_out( name, first_request, first_callback.complete, first_callback.abort, test_constants.SHORT_TIMEOUT) self.stub.event_value_in_value_out( name, second_request, second_callback.complete, second_callback.abort, test_constants.SHORT_TIMEOUT) first_callback.block_until_terminated() second_callback.block_until_terminated() first_response = first_callback.response() second_response = second_callback.response() test_messages.verify(first_request, first_response, self) test_messages.verify(second_request, second_response, self)
def testExpiredStreamRequestUnaryResponse(self): for name, test_messages_sequence in ( self.digest.stream_unary_messages_sequences.iteritems()): for unused_test_messages in test_messages_sequence: callback = testing_callback.Callback() self.stub.event_stream_in_value_out( name, callback.complete, callback.abort, test_constants.SHORT_TIMEOUT) callback.block_until_terminated() self.assertEqual(interfaces.Abortion.EXPIRED, callback.abortion())
def testSuccessfulUnaryRequestStreamResponse(self): for name, test_messages_sequence in ( self.digest.unary_stream_messages_sequences.iteritems()): for test_messages in test_messages_sequence: request = test_messages.request() callback = testing_callback.Callback() self.stub.event_value_in_stream_out( name, request, callback, callback.abort, test_constants.SHORT_TIMEOUT) callback.block_until_terminated() responses = callback.responses() test_messages.verify(request, responses, self)
def testCancelledStreamRequestStreamResponse(self): for name, test_messages_sequence in ( self.digest.stream_stream_messages_sequences.iteritems()): for unused_test_messages in test_messages_sequence: callback = testing_callback.Callback() call, unused_request_consumer = self.stub.event_stream_in_stream_out( name, callback, callback.abort, test_constants.SHORT_TIMEOUT) call.cancel() callback.block_until_terminated() self.assertEqual(interfaces.Abortion.CANCELLED, callback.abortion())
def testCancelledUnaryRequestStreamResponse(self): for name, test_messages_sequence in ( self.digest.unary_stream_messages_sequences.iteritems()): for test_messages in test_messages_sequence: request = test_messages.request() callback = testing_callback.Callback() call = self.stub.event_value_in_stream_out( name, request, callback, callback.abort, test_constants.SHORT_TIMEOUT) call.cancel() callback.block_until_terminated() self.assertEqual(interfaces.Abortion.CANCELLED, callback.abortion())
def testFailedUnaryRequestStreamResponse(self): for name, test_messages_sequence in ( self.digest.unary_stream_messages_sequences.iteritems()): for test_messages in test_messages_sequence: request = test_messages.request() callback = testing_callback.Callback() with self.control.fail(): self.stub.event_value_in_stream_out( name, request, callback, callback.abort, test_constants.SHORT_TIMEOUT) callback.block_until_terminated() self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, callback.abortion())
def testExpiredUnaryRequestUnaryResponse(self): for name, test_messages_sequence in ( self.digest.unary_unary_messages_sequences.iteritems()): for test_messages in test_messages_sequence: request = test_messages.request() callback = testing_callback.Callback() with self.control.pause(): self.stub.event_value_in_value_out( name, request, callback.complete, callback.abort, test_constants.SHORT_TIMEOUT) callback.block_until_terminated() self.assertEqual(interfaces.Abortion.EXPIRED, callback.abortion())
def testExpiredStreamRequestStreamResponse(self): for name, test_messages_sequence in ( self.digest.stream_stream_messages_sequences.iteritems()): for test_messages in test_messages_sequence: requests = test_messages.requests() callback = testing_callback.Callback() unused_call, request_consumer = self.stub.event_stream_in_stream_out( name, callback, callback.abort, test_constants.SHORT_TIMEOUT) for request in requests: request_consumer.consume(request) callback.block_until_terminated() self.assertEqual(interfaces.Abortion.EXPIRED, callback.abortion())
def testCancelledStreamRequestUnaryResponse(self): for name, test_messages_sequence in ( self.digest.stream_unary_messages_sequences.iteritems()): for test_messages in test_messages_sequence: requests = test_messages.requests() callback = testing_callback.Callback() call, request_consumer = self.stub.event_stream_in_value_out( name, callback.complete, callback.abort, test_constants.SHORT_TIMEOUT) for request in requests: request_consumer.consume(request) call.cancel() callback.block_until_terminated() self.assertEqual(interfaces.Abortion.CANCELLED, callback.abortion())
def testSuccessfulStreamRequestStreamResponse(self): for name, test_messages_sequence in ( self.digest.stream_stream_messages_sequences.iteritems()): for test_messages in test_messages_sequence: requests = test_messages.requests() callback = testing_callback.Callback() unused_call, request_consumer = self.stub.event_stream_in_stream_out( name, callback, callback.abort, test_constants.SHORT_TIMEOUT) for request in requests: request_consumer.consume(request) request_consumer.terminate() callback.block_until_terminated() responses = callback.responses() test_messages.verify(requests, responses, self)
def testFailedStreamRequestStreamResponse(self): for name, test_messages_sequence in ( self.digest.stream_stream_messages_sequences.iteritems()): for test_messages in test_messages_sequence: requests = test_messages.requests() callback = testing_callback.Callback() with self.control.fail(): unused_call, request_consumer = self.stub.event_stream_in_stream_out( name, callback, callback.abort, test_constants.SHORT_TIMEOUT) for request in requests: request_consumer.consume(request) request_consumer.terminate() callback.block_until_terminated() self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, callback.abortion())