def quit(self, args): client = args[0] client.sendPacket(PacketQuit()) client.transport.loseConnection() def serverPingTimeout(val): self.assertTrue(log_history.search("sendPacket: QUIT type = 7 length = 3")) client.connection_lost_deferred.addCallback(serverPingTimeout) return client.connection_lost_deferred
def quit(self, args): client = args[0] client.sendPacket(PacketQuit()) client.transport.loseConnection() server = self.server_factory.instance def serverPingTimeout(val): self.assertEqual(search_output("ping: timeout Mr.Fakey/-1"), True) client.connection_lost_deferred.addCallback(serverPingTimeout) silence_all_messages() return client.connection_lost_deferred
def exception(self, client): client.sendPacket(PacketError()) d = client.connection_lost_deferred def validate(result, count): server_protocol = self.server_factory.instance if server_protocol.exception: self.assertEquals("EXCEPTION TEST", str(server_protocol.exception[1])) else: if count == 0: self.fail("exception was not received") else: reactor.callLater(1, lambda: validate(result, count -1)) d.addCallback(lambda result: validate(result, 5)) return d
def sendLostConnectionPacket(val): client.sendPacket(PacketPing()) self.assertEqual(self.messageValue.find("ufferized") >= 0, True) self.assertEqual(len(client.bufferized_packets), 1) self.assertEqual(client.bufferized_packets[0].type, PACKET_PING)
def pingExpectingPrefix(self, client): clear_all_messages() client.sendPacket(PacketPing()) self.assertEquals(get_messages(), ["ATesterPrefix: sendPacket(0) type = PING(5) "]) return (client, )
def ping(self, client): clear_all_messages() client.sendPacket(PacketPing()) self.assertEquals(get_messages(), ["sendPacket(0) type = PING(5) "]) return (client, )
def sendLostConnectionPacket(val): client.sendPacket(PacketPing()) self.assertTrue(log_history.search("bufferized")) self.assertEqual(len(client.bufferized_packets), 1) self.assertEqual(client.bufferized_packets[0].type, PACKET_PING)
def ping(self, client): log_history.reset() client.sendPacket(PacketPing()) self.assertEquals(log_history.get_all(), ["sendPacket: PING type = 5 length = 3"]) return (client,)