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)
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)
from unittest import mock import pytest from thrift.protocol import TBinaryProtocol from thrift.protocol import THeaderProtocol from thrift.Thrift import TException from thrift.transport import THeaderTransport from thrift.transport import TSocket from thrift.transport import TTransport from baseplate.lib import config from baseplate.lib import thrift_pool from baseplate.observers.timeout import ServerTimeout EXAMPLE_ENDPOINT = config.EndpointConfiguration(socket.AF_INET, ("127.0.0.1", 1234)) class MakeTransportTests(unittest.TestCase): 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) 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)