コード例 #1
0
 def testUnaryCallFutureFailed(self):
     service = _CreateService()
     request = request_pb2.SimpleRequest(response_size=13)
     with service.servicer_methods.fail():
         response_future = service.stub.UnaryCall.future(request)
         self.assertIsNotNone(response_future.exception())
     self.assertIs(response_future.code(), grpc.StatusCode.UNKNOWN)
コード例 #2
0
 def testIncompleteServicer(self):
     service = _CreateIncompleteService()
     request = request_pb2.SimpleRequest(response_size=13)
     with self.assertRaises(grpc.RpcError) as exception_context:
         service.stub.UnaryCall(request)
     self.assertIs(exception_context.exception.code(),
                   grpc.StatusCode.UNIMPLEMENTED)
コード例 #3
0
 def testUnaryCall(self):
     service = _CreateService()
     request = request_pb2.SimpleRequest(response_size=13)
     response = service.stub.UnaryCall(request)
     expected_response = service.servicer_methods.UnaryCall(
         request, 'not a real context!')
     self.assertEqual(expected_response, response)
コード例 #4
0
 def testUnaryCallFutureFailed(self):
     with _CreateService() as (methods, stub):
         request = request_pb2.SimpleRequest(response_size=13)
         with methods.fail():
             response_future = stub.UnaryCall.future(
                 request, test_constants.LONG_TIMEOUT)
             self.assertIsNotNone(response_future.exception())
コード例 #5
0
 def testIncompleteServicer(self):
   with _CreateIncompleteService() as (_, stub):
     request = request_pb2.SimpleRequest(response_size=13)
     try:
       stub.UnaryCall(request, test_constants.LONG_TIMEOUT)
     except face.AbortionError as error:
       self.assertEqual(interfaces.StatusCode.UNIMPLEMENTED, error.code)
コード例 #6
0
 def testUnaryCallFutureCancelled(self):
     with _CreateService() as (methods, stub):
         request = request_pb2.SimpleRequest(response_size=13)
         with methods.pause():
             response_future = stub.UnaryCall.future(request, 1)
             response_future.cancel()
             self.assertTrue(response_future.cancelled())
コード例 #7
0
 def testUnaryCallFutureCancelled(self):
     service = _CreateService()
     request = request_pb2.SimpleRequest(response_size=13)
     with service.servicer_methods.pause():
         response_future = service.stub.UnaryCall.future(request)
         response_future.cancel()
     self.assertTrue(response_future.cancelled())
     self.assertIs(response_future.code(), grpc.StatusCode.CANCELLED)
コード例 #8
0
 def testUnaryCallFutureExpired(self):
     with _CreateService() as (methods, stub):
         request = request_pb2.SimpleRequest(response_size=13)
         with methods.pause():
             response_future = stub.UnaryCall.future(
                 request, test_constants.SHORT_TIMEOUT)
             with self.assertRaises(face.ExpirationError):
                 response_future.result()
コード例 #9
0
 def testUnaryCallInsecureSugar(self):
     request = request_pb2.SimpleRequest(response_size=13)
     response = service_pb2_grpc.TestService.UnaryCall(request,
                                                       self._target,
                                                       insecure=True,
                                                       wait_for_ready=True)
     expected_response = self.servicer_methods.UnaryCall(
         request, 'not a real context!')
     self.assertEqual(expected_response, response)
コード例 #10
0
 def testUnaryCallFuture(self):
     service = _CreateService()
     request = request_pb2.SimpleRequest(response_size=13)
     # Check that the call does not block waiting for the server to respond.
     with service.servicer_methods.pause():
         response_future = service.stub.UnaryCall.future(request)
     response = response_future.result()
     expected_response = service.servicer_methods.UnaryCall(
         request, 'not a real RpcContext!')
     self.assertEqual(expected_response, response)
コード例 #11
0
 def testUnaryCallFuture(self):
   with _CreateService() as (methods, stub):
     request = request_pb2.SimpleRequest(response_size=13)
     # Check that the call does not block waiting for the server to respond.
     with methods.pause():
       response_future = stub.UnaryCall.future(
           request, test_constants.LONG_TIMEOUT)
     response = response_future.result()
   expected_response = methods.UnaryCall(request, 'not a real RpcContext!')
   self.assertEqual(expected_response, response)
コード例 #12
0
 def testUnaryCall(self):
     request = request_pb2.SimpleRequest(response_size=13)
     response = service_pb2_grpc.TestService.UnaryCall(
         request,
         self._target,
         channel_credentials=grpc.experimental.insecure_channel_credentials(
         ),
         wait_for_ready=True)
     expected_response = self.servicer_methods.UnaryCall(
         request, 'not a real context!')
     self.assertEqual(expected_response, response)
コード例 #13
0
ファイル: _python_plugin_test.py プロジェクト: txl0591/grpc1
 def testUnaryCallFutureExpired(self):
     service = _CreateService()
     request = request_pb2.SimpleRequest(response_size=13)
     with service.servicer_methods.pause():
         response_future = service.stub.UnaryCall.future(
             request, timeout=test_constants.SHORT_TIMEOUT)
         with self.assertRaises(grpc.RpcError) as exception_context:
             response_future.result()
     self.assertIs(exception_context.exception.code(),
                   grpc.StatusCode.DEADLINE_EXCEEDED)
     self.assertIs(response_future.code(), grpc.StatusCode.DEADLINE_EXCEEDED)
コード例 #14
0
 def testUnaryCall(self):
     with _CreateService() as (methods, stub):
         request = request_pb2.SimpleRequest(response_size=13)
         response = stub.UnaryCall(request, test_constants.LONG_TIMEOUT)
     expected_response = methods.UnaryCall(request, 'not a real context!')
     self.assertEqual(expected_response, response)
コード例 #15
0
 def testUpDown(self):
     with _CreateService():
         request_pb2.SimpleRequest(response_size=13)