def test_ListenRecvExit(self): server = ListenRecvExit() serverProcess, port = genericServer.StartServer(server) # Create the udp socket sock = comms.udp() # Send the message to the server comms.sendMessage(sock, 'test', comms.OK, (genericServer.ADDR, port)) # Receive a message response, serverAddr = sock.recvfrom(comms.RECV_SIZE) # Parse the response and return it reply, status = comms.parseMessage(response) # Stop the server serverProcess.terminate() # If the test errored self.assertEqual(EXIT_MESSAGE, reply, \ 'Server reply is not exit message {0}'.format(reply)) self.assertEqual(comms.EXIT, status, \ 'Server did not exit, status code {0}'.format(status))
def __init__(self): """ Creates a udp socket that will be used to send data. """ super(Client, self).__init__() self.sock = comms.udp()