Exemplo n.º 1
0
 def testUnaryCall(self):
   import test_pb2  # pylint: disable=g-import-not-at-top
   with _CreateService(test_pb2, NO_DELAY) as (servicer, stub, unused_server):
     request = test_pb2.SimpleRequest(response_size=13)
     response = stub.UnaryCall(request, NORMAL_TIMEOUT)
   expected_response = servicer.UnaryCall(request, None)
   self.assertEqual(expected_response, response)
Exemplo n.º 2
0
 def testUnaryCall(self):
   import test_pb2  # pylint: disable=g-import-not-at-top
   with _CreateService(test_pb2) as (methods, stub):
     request = test_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)
Exemplo n.º 3
0
 def testUpDown(self):
     import test_pb2
     servicer, stub, server = _CreateService(test_pb2,
                                             DOES_NOT_MATTER_DELAY)
     request = test_pb2.SimpleRequest(response_size=13)
     with server, stub:
         pass
Exemplo n.º 4
0
 def testUnaryCallAsyncFailed(self):
   import test_pb2  # pylint: disable=g-import-not-at-top
   request = test_pb2.SimpleRequest(response_size=13)
   with _CreateService(test_pb2, NO_DELAY) as (
       methods, stub, unused_server):
     with methods.fail():
       response_future = stub.UnaryCall.async(request, LONG_TIMEOUT)
       self.assertIsNotNone(response_future.exception())
Exemplo n.º 5
0
 def testUnaryCall(self):
   import test_pb2  # pylint: disable=g-import-not-at-top
   with _CreateService(test_pb2, NO_DELAY) as (methods, stub, unused_server):
     timeout = 6  # TODO(issue 2039): LONG_TIMEOUT like the other methods.
     request = test_pb2.SimpleRequest(response_size=13)
     response = stub.UnaryCall(request, timeout)
   expected_response = methods.UnaryCall(request, 'not a real RpcContext!')
   self.assertEqual(expected_response, response)
Exemplo n.º 6
0
 def testUnaryCallFutureFailed(self):
   import test_pb2  # pylint: disable=g-import-not-at-top
   request = test_pb2.SimpleRequest(response_size=13)
   with _CreateService(test_pb2) as (methods, stub):
     with methods.fail():
       response_future = stub.UnaryCall.future(
           request, test_constants.LONG_TIMEOUT)
       self.assertIsNotNone(response_future.exception())
Exemplo n.º 7
0
 def testUnaryCallFutureCancelled(self):
   import test_pb2  # pylint: disable=g-import-not-at-top
   request = test_pb2.SimpleRequest(response_size=13)
   with _CreateService(test_pb2) as (methods, stub):
     with methods.pause():
       response_future = stub.UnaryCall.future(request, 1)
       response_future.cancel()
       self.assertTrue(response_future.cancelled())
Exemplo n.º 8
0
 def testUnaryCallAsyncExpired(self):
   import test_pb2  # pylint: disable=g-import-not-at-top
   with _CreateService(test_pb2, NO_DELAY) as (
       methods, stub, unused_server):
     request = test_pb2.SimpleRequest(response_size=13)
     with methods.pause():
       response_future = stub.UnaryCall.async(request, SHORT_TIMEOUT)
       with self.assertRaises(exceptions.ExpirationError):
         response_future.result()
Exemplo n.º 9
0
 def testUnaryCallFutureExpired(self):
   import test_pb2  # pylint: disable=g-import-not-at-top
   with _CreateService(test_pb2) as (methods, stub):
     request = test_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()
Exemplo n.º 10
0
 def testUnaryCallAsyncCancelled(self):
   import test_pb2  # pylint: disable=g-import-not-at-top
   request = test_pb2.SimpleRequest(response_size=13)
   with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as (
       servicer, stub, unused_server):
     with servicer.pause():
       response_future = stub.UnaryCall.async(request, 1)
       response_future.cancel()
       self.assertTrue(response_future.cancelled())
Exemplo n.º 11
0
 def testUnaryCallAsyncExpired(self):
   import test_pb2  # pylint: disable=g-import-not-at-top
   # set the timeout super low...
   with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as (
       servicer, stub, unused_server):
     request = test_pb2.SimpleRequest(response_size=13)
     with servicer.pause():
       response_future = stub.UnaryCall.async(request, SHORT_TIMEOUT)
       with self.assertRaises(exceptions.ExpirationError):
         response_future.result()
Exemplo n.º 12
0
 def testUnaryCallAsyncFailed(self):
     import test_pb2  # pylint: disable=g-import-not-at-top
     servicer, stub, server = _CreateService(test_pb2,
                                             DOES_NOT_MATTER_DELAY)
     request = test_pb2.SimpleRequest(response_size=13)
     with server, stub:
         with servicer.fail():
             response_future = stub.UnaryCall. async (request,
                                                      NORMAL_TIMEOUT)
             self.assertIsNotNone(response_future.exception())
Exemplo n.º 13
0
 def testUnaryCallAsync(self):
   import test_pb2  # pylint: disable=g-import-not-at-top
   request = test_pb2.SimpleRequest(response_size=13)
   with _CreateService(test_pb2, NO_DELAY) as (
       methods, stub, unused_server):
     # Check that the call does not block waiting for the server to respond.
     with methods.pause():
       response_future = stub.UnaryCall.async(request, LONG_TIMEOUT)
     response = response_future.result()
   expected_response = methods.UnaryCall(request, 'not a real RpcContext!')
   self.assertEqual(expected_response, response)
Exemplo n.º 14
0
 def testUnaryCallAsync(self):
     import test_pb2  # pylint: disable=g-import-not-at-top
     request = test_pb2.SimpleRequest(response_size=13)
     with _CreateService(test_pb2,
                         LONG_DELAY) as (servicer, stub, unused_server):
         start_time = time.clock()
         response_future = stub.UnaryCall. async (request, LONG_TIMEOUT)
         # Check that we didn't block on the asynchronous call.
         self.assertGreater(LONG_DELAY, time.clock() - start_time)
         response = response_future.result()
     expected_response = servicer.UnaryCall(request, None)
     self.assertEqual(expected_response, response)
Exemplo n.º 15
0
 def testUpDown(self):
     import test_pb2
     with _CreateService(test_pb2,
                         DOES_NOT_MATTER_DELAY) as (servicer, stub,
                                                    unused_server):
         request = test_pb2.SimpleRequest(response_size=13)
Exemplo n.º 16
0
 def testUpDown(self):
   import test_pb2
   with _CreateService(test_pb2) as (servicer, stub):
     request = test_pb2.SimpleRequest(response_size=13)