Example #1
0
    def testSequentialInvocations(self):
        # pylint: disable=cell-var-from-loop
        for (group, method), 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()
                second_receiver = _receiver.Receiver()

                def make_second_invocation():
                    self._invoker.event(group,
                                        method)(second_request,
                                                second_receiver,
                                                second_receiver.abort,
                                                test_constants.LONG_TIMEOUT)

                class FirstReceiver(_receiver.Receiver):
                    def complete(self, terminal_metadata, code, details):
                        super(FirstReceiver,
                              self).complete(terminal_metadata, code, details)
                        make_second_invocation()

                first_receiver = FirstReceiver()

                self._invoker.event(group,
                                    method)(first_request, first_receiver,
                                            first_receiver.abort,
                                            test_constants.LONG_TIMEOUT)
                second_receiver.block_until_terminated()

                first_response = first_receiver.unary_response()
                second_response = second_receiver.unary_response()
                test_messages.verify(first_request, first_response, self)
                test_messages.verify(second_request, second_response, self)
Example #2
0
    def testExpiredStreamRequestUnaryResponse(self):
        for (group, method), test_messages_sequence in (
                self._digest.stream_unary_messages_sequences.iteritems()):
            for unused_test_messages in test_messages_sequence:
                receiver = _receiver.Receiver()

                self._invoker.event(
                    group, method)(receiver, receiver.abort,
                                   _3069_test_constant.REALLY_SHORT_TIMEOUT)
                receiver.block_until_terminated()

                self.assertIs(face.Abortion.Kind.EXPIRED,
                              receiver.abortion().kind)
Example #3
0
    def testCancelledStreamRequestStreamResponse(self):
        for (group, method), test_messages_sequence in (
                self._digest.stream_stream_messages_sequences.iteritems()):
            for unused_test_messages in test_messages_sequence:
                receiver = _receiver.Receiver()

                call_consumer = self._invoker.event(group, method)(
                    receiver, receiver.abort, test_constants.LONG_TIMEOUT)
                call_consumer.cancel()
                receiver.block_until_terminated()

                self.assertIs(face.Abortion.Kind.CANCELLED,
                              receiver.abortion().kind)
Example #4
0
    def testSuccessfulUnaryRequestStreamResponse(self):
        for (group, method), test_messages_sequence in (
                self._digest.unary_stream_messages_sequences.iteritems()):
            for test_messages in test_messages_sequence:
                request = test_messages.request()
                receiver = _receiver.Receiver()

                self._invoker.event(group,
                                    method)(request, receiver, receiver.abort,
                                            test_constants.LONG_TIMEOUT)
                receiver.block_until_terminated()
                responses = receiver.stream_responses()

                test_messages.verify(request, responses, self)
Example #5
0
    def testParallelInvocations(self):
        for (group, method), test_messages_sequence in (
                self._digest.unary_unary_messages_sequences.iteritems()):
            for test_messages in test_messages_sequence:
                first_request = test_messages.request()
                first_receiver = _receiver.Receiver()
                second_request = test_messages.request()
                second_receiver = _receiver.Receiver()

                self._invoker.event(group,
                                    method)(first_request, first_receiver,
                                            first_receiver.abort,
                                            test_constants.LONG_TIMEOUT)
                self._invoker.event(group,
                                    method)(second_request, second_receiver,
                                            second_receiver.abort,
                                            test_constants.LONG_TIMEOUT)
                first_receiver.block_until_terminated()
                second_receiver.block_until_terminated()

                first_response = first_receiver.unary_response()
                second_response = second_receiver.unary_response()
                test_messages.verify(first_request, first_response, self)
                test_messages.verify(second_request, second_response, self)
Example #6
0
    def testFailedUnaryRequestStreamResponse(self):
        for (group, method), test_messages_sequence in (
                self._digest.unary_stream_messages_sequences.iteritems()):
            for test_messages in test_messages_sequence:
                request = test_messages.request()
                receiver = _receiver.Receiver()

                with self._control.fail():
                    self._invoker.event(group,
                                        method)(request, receiver,
                                                receiver.abort,
                                                test_constants.LONG_TIMEOUT)
                    receiver.block_until_terminated()

                self.assertIs(face.Abortion.Kind.REMOTE_FAILURE,
                              receiver.abortion().kind)
Example #7
0
    def testExpiredStreamRequestStreamResponse(self):
        for (group, method), test_messages_sequence in (
                self._digest.stream_stream_messages_sequences.iteritems()):
            for test_messages in test_messages_sequence:
                requests = test_messages.requests()
                receiver = _receiver.Receiver()

                call_consumer = self._invoker.event(
                    group, method)(receiver, receiver.abort,
                                   _3069_test_constant.REALLY_SHORT_TIMEOUT)
                for request in requests:
                    call_consumer.consume(request)
                receiver.block_until_terminated()

                self.assertIs(face.Abortion.Kind.EXPIRED,
                              receiver.abortion().kind)
Example #8
0
    def testCancelledUnaryRequestUnaryResponse(self):
        for (group, method), test_messages_sequence in (
                self._digest.unary_unary_messages_sequences.iteritems()):
            for test_messages in test_messages_sequence:
                request = test_messages.request()
                receiver = _receiver.Receiver()

                with self._control.pause():
                    call = self._invoker.event(
                        group, method)(request, receiver, receiver.abort,
                                       test_constants.LONG_TIMEOUT)
                    call.cancel()
                    receiver.block_until_terminated()

                self.assertIs(face.Abortion.Kind.CANCELLED,
                              receiver.abortion().kind)
Example #9
0
    def testSuccessfulStreamRequestStreamResponse(self):
        for (group, method), test_messages_sequence in (
                self._digest.stream_stream_messages_sequences.iteritems()):
            for test_messages in test_messages_sequence:
                requests = test_messages.requests()
                receiver = _receiver.Receiver()

                call_consumer = self._invoker.event(group, method)(
                    receiver, receiver.abort, test_constants.LONG_TIMEOUT)
                for request in requests:
                    call_consumer.consume(request)
                call_consumer.terminate()
                receiver.block_until_terminated()
                responses = receiver.stream_responses()

                test_messages.verify(requests, responses, self)