コード例 #1
0
    def test_listener(self):
        message = "hello world"

        def test_packet(chat_packet):
            self.assertEqual(chat_packet.message, message)

        listener = PacketListener(test_packet, ChatPacket)

        packet = ChatPacket().set_values(message=message)
        uncalled_packet = KeepAlivePacket().set_values(keep_alive_id=0)

        listener.call_packet(packet)
        listener.call_packet(uncalled_packet)
コード例 #2
0
    def test_listener(self):
        message = "hello world"

        def test_packet(chat_packet):
            self.assertEqual(chat_packet.message, message)

        for protocol_version in SUPPORTED_PROTOCOL_VERSIONS:
            context = ConnectionContext(protocol_version=protocol_version)

            listener = PacketListener(test_packet, ChatPacket)

            packet = ChatPacket(context).set_values(message=message)
            uncalled_packet = KeepAlivePacket().set_values(keep_alive_id=0)

            listener.call_packet(packet)
            listener.call_packet(uncalled_packet)
コード例 #3
0
ファイル: test_packets.py プロジェクト: Siphala/pyCraft
    def test_listener(self):
        message = "hello world"

        def test_packet(chat_packet):
            self.assertEqual(chat_packet.message, message)

        for protocol_version in TEST_VERSIONS:
            logging.debug('protocol_version = %r' % protocol_version)
            context = ConnectionContext(protocol_version=protocol_version)

            listener = PacketListener(test_packet, serverbound.play.ChatPacket)

            packet = serverbound.play.ChatPacket(context).set_values(
                message=message)
            uncalled_packet = KeepAlivePacket().set_values(keep_alive_id=0)

            listener.call_packet(packet)
            listener.call_packet(uncalled_packet)