Beispiel #1
0
 def test_client_type_and_protocol(self) -> None:
     with server_in_another_process() as path:
         with get_sync_client(
             TestService,
             path=path,
             client_type=ClientType.THRIFT_ROCKET_CLIENT_TYPE,
             protocol=Protocol.BINARY,
         ) as client:
             sum = client.add(1, 2)
             self.assertEqual(3, sum)
Beispiel #2
0
 def test_transport_error(self) -> None:
     with get_sync_client(TestService, path="/no/where") as client:
         with self.assertRaises(TransportError) as ex:
             client.add(1, 2)
         self.assertEqual(TransportErrorType.UNKNOWN, ex.exception.type)
Beispiel #3
0
 def test_deriving_from_external_service(self) -> None:
     with server_in_another_process() as path:
         with get_sync_client(LeafService, path=path) as client:
             self.assertEqual([3, 2, 1], list(client.reverse([1, 2, 3])))
             self.assertEqual("hello", client.echo("hello"))
             self.assertEqual(3, client.add(1, 2))
Beispiel #4
0
 def test_derived_service(self) -> None:
     with server_in_another_process() as path:
         with get_sync_client(EchoService, path=path) as client:
             self.assertEqual("hello", client.echo("hello"))
             self.assertEqual(3, client.add(1, 2))
Beispiel #5
0
 def test_unexpected_exception(self) -> None:
     with server_in_another_process() as path:
         with get_sync_client(TestService, path=path) as client:
             with self.assertRaisesRegex(ApplicationError, "Surprise!") as ex:
                 client.surprise()
             self.assertEqual(ApplicationErrorType.UNKNOWN, ex.exception.type)
Beispiel #6
0
 def test_oneway(self) -> None:
     with server_in_another_process() as path:
         with get_sync_client(TestService, path=path) as client:
             self.assertIsNone(client.oneway())
             time.sleep(1)  # wait for server to clear the queue
Beispiel #7
0
 def test_void_return_with_exception(self) -> None:
     with server_in_another_process() as path:
         with get_sync_client(TestService, path=path) as client:
             with self.assertRaises(EmptyException):
                 client.oops()
Beispiel #8
0
 def test_exception(self) -> None:
     with server_in_another_process() as path:
         with get_sync_client(TestService, path=path) as client:
             self.assertAlmostEqual(2, client.divide(6, 3))
             with self.assertRaises(ArithmeticException):
                 client.divide(1, 0)
Beispiel #9
0
 def test_void_return(self) -> None:
     with server_in_another_process() as path:
         with get_sync_client(TestService, path=path) as client:
             self.assertIsNone(client.noop())
Beispiel #10
0
 def test_basic(self) -> None:
     with server_in_another_process() as path:
         with get_sync_client(TestService, path=path) as client:
             self.assertEqual(3, client.add(1, 2))
Beispiel #11
0
 def test_persistent_header(self) -> None:
     with server_in_another_process() as path:
         with get_sync_client(TestService, path=path) as client:
             client.set_persistent_header(TEST_HEADER_KEY, TEST_HEADER_VALUE)
             self.assertEqual(TEST_HEADER_VALUE, client.readHeader(TEST_HEADER_KEY))