def test_pool_with_framed_protocol_factory(self): def framed_protocol_factory(trans): trans = TTransport.TFramedTransport(trans) return TBinaryProtocol.TBinaryProtocol(trans) framed_pool = thrift_pool.ThriftConnectionPool(EXAMPLE_ENDPOINT, protocol_factory=framed_protocol_factory) trans = thrift_pool._make_transport(EXAMPLE_ENDPOINT) prot = framed_pool.protocol_factory(trans) self.assertTrue(isinstance(prot, TBinaryProtocol.TBinaryProtocol)) self.assertTrue(isinstance(prot.trans, TTransport.TFramedTransport))
def test_unix(self): endpoint = config.EndpointConfiguration( socket.AF_UNIX, "/tmp/socket") socket_transport = thrift_pool._make_transport(endpoint) self.assertTrue(socket_transport._unix_socket)
def test_unknown(self): endpoint = config.EndpointConfiguration( socket.AF_UNSPEC, None) with self.assertRaises(Exception): thrift_pool._make_transport(endpoint)
def test_inet(self): endpoint = config.EndpointConfiguration( socket.AF_INET, ("localhost", 1234)) socket_transport = thrift_pool._make_transport(endpoint) self.assertFalse(socket_transport._unix_socket)