def test_pingd(self): packet = PingD(data='test_data') serialized_packet = packet.pack() self.socket.sendall(serialized_packet) reply = Packet.unpack(get_msg(self.socket)) self.assertIsInstance(reply, PongD) self.assertEqual(packet.data, reply.data)
def test_finish(self): packet = Finish().pack() self.socket.sendall(packet) reply = Packet.unpack(get_msg(self.socket)) self.assertIsInstance(reply, AckFinish) self.server.wait(timeout=self.TERMINATE_TIMEOUT) self.assertTrue(self.server.poll() is not None)
def test_finish(self): packet = Finish().pack() self.socket.sendall(packet) reply = Packet.unpack(get_msg(self.socket)) self.assertIsInstance(reply, AckFinish) while True: if not os.path.exists(self.PID_FILE): time.sleep(0.5) break self.assertTrue(self.server.poll() is not None)
def test_quit(self): packet = Quit().pack() self.socket.sendall(packet) reply = Packet.unpack(get_msg(self.socket)) self.assertIsInstance(reply, AckQuit) self.assertTrue(hasattr(reply, 'session'))
def test_ping(self): packet = Ping().pack() self.socket.sendall(packet) reply = Packet.unpack(get_msg(self.socket)) self.assertIsInstance(reply, Pong)
def test_connect(self): packet = Connect().pack() self.socket.sendall(packet) reply = Packet.unpack(get_msg(self.socket)) self.assertIsInstance(reply, Connected) self.assertTrue(hasattr(reply, 'session'))