def client(message): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: ip = 'localhost' port = get_free_port() sock.connect((ip, port)) sock.sendall(bytes(message, 'ascii')) response = str(sock.recv(1024), 'ascii') yield response sock.shutdown(socket.SHUT_RDWR) sock.close()
def server(): HOST = "localhost" mock_server_port = get_free_port() start_tcp_main_server(HOST, mock_server_port) req = TupleSpaceClient(HOST, mock_server_port) return req
def setup_mock_kafka_connect_api(mock_name): kafka_connect_port = mocks.get_free_port() mocks.start_mock_server(kafka_connect_port, mock_name) return kafka_connect_port
def setup_class(cls): cls.mock_server_port = get_free_port() start_mock_server(cls.mock_server_port)
def server1(): mock_server_port = get_free_port() start_tcp_mock_server(HOST, mock_server_port) req = TupleSpaceClient(HOST, mock_server_port) return req
def setUp(self): self.mock_server_port = get_free_port() start_mock_server(self.mock_server_port)
def setup_mock_server(mock_name): mock_port = mocks.get_free_port() mocks.start_mock_server(mock_port, mock_name) return mock_port