def test_server(self): """Test http server""" test_dir, application = self.create_server() # Prepare server thread server = Server(('localhost', 0), application.rest) server.prepare() server_port = server.bind_addr[1] thread = threading.Thread(target=server.serve) thread.start() # Run test response = urlopen('http://localhost:{}/en/cs/unit/Hello/'.format(server_port)) payload = json.loads(response.read().decode('utf-8')) assert payload[0]['target'] == 'Ahoj' # Shutdown the server thread server.stop() thread.join() self.cleanup(test_dir, application)
def test_server(self): """Test http server""" test_dir, application = self.create_server() # Prepare server thread server = Server(("localhost", 0), application.rest) server.prepare() server_port = server.bind_addr[1] thread = threading.Thread(target=server.serve) thread.start() # Run test response = urlopen(f"http://localhost:{server_port}/en/cs/unit/Hello/") payload = json.loads(response.read().decode("utf-8")) assert payload[0]["target"] == "Ahoj" # Shutdown the server thread server.stop() thread.join() self.cleanup(test_dir, application)
def test_server(self): """Test http server""" test_dir, application = self.create_server() # Prepare server thread server = Server(('localhost', 0), application.rest) server.prepare() server_port = server.bind_addr[1] thread = threading.Thread(target=server.serve) thread.start() # Run test response = urlopen( 'http://localhost:{}/en/cs/unit/Hello/'.format(server_port)) payload = json.loads(response.read().decode('utf-8')) assert payload[0]['target'] == 'Ahoj' # Shutdown the server thread server.stop() thread.join() self.cleanup(test_dir, application)