コード例 #1
0
    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))
コード例 #2
0
    def test_unknown(self):
        endpoint = config.EndpointConfiguration(socket.AF_UNSPEC, None)

        with self.assertRaises(Exception):
            thrift_pool._make_transport(endpoint)
コード例 #3
0
    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)
コード例 #4
0
    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)