def test_case5(self): # start server thread t = threading.Thread(target=mockServer) t.start() # use functions in client source code to do normal operation clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) client_python_udp.sendCommand(clientSocket, "localhost", serverPort, "ls") rc = client_python_udp.receiveDataToFile(clientSocket, "debugOutput.txt") self.assertEqual(rc, "Did not receive response.") # check server function return value t.join(5.0) self.assertFalse(t.is_alive()) # server thread should have completed
def test_case3(self): # start server thread que = queue.Queue() t = threading.Thread(target=threadServer, args=(que,)) t.start() # use functions in client source code to send command clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) client_python_udp.sendCommand(clientSocket, "localhost", serverPort, "ls") # check server function return value t.join(5.0) self.assertFalse(t.is_alive()) # server thread should have completed self.assertEqual(que.get(), "File transmission failed.")
def test_case1(self): # start server thread que = queue.Queue() t = threading.Thread(target=threadServer, args=(que,)) t.start() # use functions in client source code to do normal operation clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) client_python_udp.sendCommand(clientSocket, "localhost", serverPort, "ls") client_python_udp.receiveDataToFile(clientSocket, "debugOutput.txt") # check server function return value t.join(5.0) self.assertFalse(t.is_alive()) # server thread should have completed self.assertEqual(que.get(), "Successful file transmission.")
def test_case3(self): # indicate server is not running clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) rc = client_python_udp.sendCommand(clientSocket, "localhost", serverPort, "ls") self.assertEqual(rc, "Failed to send command. Terminating.")