Exemplo n.º 1
0
 def test_MAP_LIST(self):  # 10
     # GIVEN
     self.parser._mapList = None
     # WHEN
     self.parser.handlePacket(Packet.decode(
         '\x00\n\x00\x00\x00E\x00\x00\x00ATD-Bamboo_small?game=CDW.AOCTD?numteams=2?class0=Open?class1=Open'
     ))
     self.parser.handlePacket(Packet.decode(
         '\x00\n\x00\x00\x00O\x00\x00\x00KPTB-Valley_small?game=CDW.PlantTheBanner?numteams=2?class0=Open?class1=Open'
     ))
     # THEN
     self.assertListEqual(['TD-Bamboo_small', 'PTB-Valley_small'], self.parser._mapList)
Exemplo n.º 2
0
 def test_getNextMap_current_map_is_last(self):
     # GIVEN
     self.parser._mapList = None
     self.parser.handlePacket(Packet.decode(
         '\x00\n\x00\x00\x00E\x00\x00\x00ATD-Bamboo_small?game=CDW.AOCTD?numteams=2?class0=Open?class1=Open'
     ))
     self.parser.handlePacket(Packet.decode(
         '\x00\n\x00\x00\x00O\x00\x00\x00KPTB-Valley_small?game=CDW.PlantTheBanner?numteams=2?class0=Open?class1=Open'
     ))
     self.parser.handlePacket(Packet.decode('\x00\t\x00\x00\x00\x18\x00\x00\x00\x01\x00\x00\x00\x10PTB-Valley_small'))
     # WHEN
     self.assertEqual("PTB-Valley_small", self.parser.getMap())
     # THEN
     self.assertEqual('TD-Bamboo_small', self.parser.getNextMap())
Exemplo n.º 3
0
 def test_MAP_LIST(self):  # 10
     # GIVEN
     self.parser._mapList = None
     # WHEN
     self.parser.handlePacket(
         Packet.decode(
             '\x00\n\x00\x00\x00E\x00\x00\x00ATD-Bamboo_small?game=CDW.AOCTD?numteams=2?class0=Open?class1=Open'
         ))
     self.parser.handlePacket(
         Packet.decode(
             '\x00\n\x00\x00\x00O\x00\x00\x00KPTB-Valley_small?game=CDW.PlantTheBanner?numteams=2?class0=Open?class1=Open'
         ))
     # THEN
     self.assertListEqual(['TD-Bamboo_small', 'PTB-Valley_small'],
                          self.parser._mapList)
Exemplo n.º 4
0
 def test_MAP_CHANGED(self):  # 9
     # GIVEN
     self.parser.game.mapName = "old"
     # WHEN
     self.parser.handlePacket(Packet.decode('\x00\t\x00\x00\x00\x0f\x00\x00\x00#\x00\x00\x00\x07TD-Isle'))
     # THEN
     self.assertEqual("TD-Isle", self.parser.game.mapName)
     self.assertEqual("TD-Isle", self.parser.getMap())
Exemplo n.º 5
0
 def test_SUICIDE(self):  # 16
     # GIVEN
     poorguy = FakeClient(self.parser, name="attacker_name", guid='76561198070138838')
     poorguy.connects("1")
     # WHEN
     self.parser.handlePacket(Packet.decode('\x00\x10\x00\x00\x00\x08\x01\x10\x00\x01\x06\x8c\x87\xd6'))
     # THEN
     self.assert_has_event("EVT_CLIENT_SUICIDE", client=poorguy, target=poorguy, data=(100, None, None))
Exemplo n.º 6
0
 def test_TEAM_CHANGED_1(self):  # 13
     # GIVEN
     player = FakeClient(self.parser, name="Pheonix", guid="76561198070138838")
     player.connects("1")
     self.assertEqual(TEAM_UNKNOWN, player.team)
     # WHEN
     self.parser.handlePacket(Packet.decode('\x00\r\x00\x00\x00\x0c\x01\x10\x00\x01\x06\x8c\x87\xd6\x00\x00\x00\x01'))
     # THEN
     self.assertEqual(1, player.team)
Exemplo n.º 7
0
 def test_NAME_CHANGED(self):  # 14
     # GIVEN
     player = FakeClient(self.parser, name="Pheonix", guid="123456789")
     player.connects("1")
     # WHEN
     self.parser.handlePacket(Packet.decode(
         '\x00\x0e\x00\x00\x00\x14\x00\x00\x00\x00\x07[\xcd\x15\x00\x00\x00\x08new name'
     ))
     # THEN
     self.assertEqual('new name', player.name)
Exemplo n.º 8
0
 def test_getNextMap_current_map_is_last(self):
     # GIVEN
     self.parser._mapList = None
     self.parser.handlePacket(
         Packet.decode(
             '\x00\n\x00\x00\x00E\x00\x00\x00ATD-Bamboo_small?game=CDW.AOCTD?numteams=2?class0=Open?class1=Open'
         ))
     self.parser.handlePacket(
         Packet.decode(
             '\x00\n\x00\x00\x00O\x00\x00\x00KPTB-Valley_small?game=CDW.PlantTheBanner?numteams=2?class0=Open?class1=Open'
         ))
     self.parser.handlePacket(
         Packet.decode(
             '\x00\t\x00\x00\x00\x18\x00\x00\x00\x01\x00\x00\x00\x10PTB-Valley_small'
         ))
     # WHEN
     self.assertEqual("PTB-Valley_small", self.parser.getMap())
     # THEN
     self.assertEqual('TD-Bamboo_small', self.parser.getNextMap())
Exemplo n.º 9
0
 def test_PLAYER_CHAT(self):  # 3
     # GIVEN
     player = FakeClient(self.parser, name="Pheonix", guid="76561198038608801")
     player.connects("1")
     self.clear_events()
     # WHEN
     self.parser.handlePacket(Packet.decode(
         '\x00\x03\x00\x00\x00\x17\x01\x10\x00\x01\x04\xabk\xa1\x00\x00\x00\x07 sorry \x00\x00\x00\x00'))
     # THEN
     self.assert_has_event("EVT_CLIENT_SAY", data='sorry', client=player)
Exemplo n.º 10
0
 def test_MAP_CHANGED(self):  # 9
     # GIVEN
     self.parser.game.mapName = "old"
     # WHEN
     self.parser.handlePacket(
         Packet.decode(
             '\x00\t\x00\x00\x00\x0f\x00\x00\x00#\x00\x00\x00\x07TD-Isle'))
     # THEN
     self.assertEqual("TD-Isle", self.parser.game.mapName)
     self.assertEqual("TD-Isle", self.parser.getMap())
Exemplo n.º 11
0
 def test_unknown_msgType(self):
     # WHEN
     with patch.object(self.parser, "warning") as warning_mock:
         self.parser.handlePacket(
             Packet.decode('\x00c\x00\x00\x00\x0f\x00\x00\x00\x00I\x96\x02\xd2\x00\x00\x00\x03f00'))
     # THEN
     self.assertListEqual([], self.evt_queue)
     self.assertListEqual([
          call("unkown RCON message type: 99. REPORT THIS TO THE B3 FORUMS. Packet.decode('\\x00c\\x00\\x00\\x00\\x0f\\x00\\x00\\x00\\x00I\\x96\\x02\\xd2\\x00\\x00\\x00\\x03f00')  # {'msgType': 99, 'dataLength': 15, 'data': '\\x00\\x00\\x00\\x00I\\x96\\x02\\xd2\\x00\\x00\\x00\\x03f00'}")
                          ], warning_mock.mock_calls)
Exemplo n.º 12
0
 def test_NAME_CHANGED(self):  # 14
     # GIVEN
     player = FakeClient(self.parser, name="Pheonix", guid="123456789")
     player.connects("1")
     # WHEN
     self.parser.handlePacket(
         Packet.decode(
             '\x00\x0e\x00\x00\x00\x14\x00\x00\x00\x00\x07[\xcd\x15\x00\x00\x00\x08new name'
         ))
     # THEN
     self.assertEqual('new name', player.name)
Exemplo n.º 13
0
 def test_PLAYER_CONNECT(self):  # 4
     # GIVEN
     self.assertIsNone(self.parser.clients.getByGUID("1234567890"))
     # WHEN
     self.parser.handlePacket(Packet.decode(
         '\x00\x04\x00\x00\x00\x13\x00\x00\x00\x00I\x96\x02\xd2\x00\x00\x00\x07player1'
     ))
     # THEN
     player = self.parser.clients.getByGUID("1234567890")
     self.assertIsNotNone(player)
     self.assertEqual('player1', player.name)
Exemplo n.º 14
0
 def test_PLAYER_CHAT_team(self):  # 3
     # GIVEN
     player = FakeClient(self.parser, name="Pheonix", guid="76561198038608801")
     player.connects("1")
     self.clear_events()
     player.team = 0  # ugly, until chiv team ids got converted into b3 team ids
     # WHEN
     self.parser.handlePacket(Packet.decode(
         '\x00\x03\x00\x00\x00\x17\x01\x10\x00\x01\x04\xabk\xa1\x00\x00\x00\x07 sorry \x00\x00\x00\x00'))
     # THEN
     self.assert_has_event("EVT_CLIENT_TEAM_SAY", data='sorry', client=player)
Exemplo n.º 15
0
 def test_PLAYER_DISCONNECT(self):  # 5
     # GIVEN
     player = FakeClient(self.parser, name="Pheonix", guid="76561198036015889")
     player.connects("1")
     self.clear_events()
     # WHEN
     self.parser.handlePacket(Packet.decode(
         '\x00\x05\x00\x00\x00\x08\x01\x10\x00\x01\x04\x83\xdb\x11'
     ))
     # THEN
     self.assert_has_event("EVT_CLIENT_DISCONNECT", data='1', client=player)
Exemplo n.º 16
0
 def test_PLAYER_CONNECT(self):  # 4
     # GIVEN
     self.assertIsNone(self.parser.clients.getByGUID("1234567890"))
     # WHEN
     self.parser.handlePacket(
         Packet.decode(
             '\x00\x04\x00\x00\x00\x13\x00\x00\x00\x00I\x96\x02\xd2\x00\x00\x00\x07player1'
         ))
     # THEN
     player = self.parser.clients.getByGUID("1234567890")
     self.assertIsNotNone(player)
     self.assertEqual('player1', player.name)
Exemplo n.º 17
0
 def test_KILL_teamkill(self):  # 15
     # GIVEN
     attacker = FakeClient(self.parser, name="attacker_name", guid='76561198036015889', team=TEAM_BLUE)
     attacker.connects("1")
     victim = FakeClient(self.parser, name="victim_name", guid='76561198021620061', team=TEAM_BLUE)
     victim.connects("2")
     # WHEN
     self.parser.handlePacket(Packet.decode(
         '\x00\x0f\x00\x00\x00\x1e\x01\x10\x00\x01\x04\x83\xdb\x11\x01\x10\x00\x01\x03\xa81]\x00\x00\x00\nTekko Kagi'
     ))
     # THEN
     self.assert_has_event("EVT_CLIENT_KILL_TEAM", client=attacker, target=victim, data=(100, u'Tekko Kagi', 'body'))
Exemplo n.º 18
0
 def test_PLAYER_DISCONNECT(self):  # 5
     # GIVEN
     player = FakeClient(self.parser,
                         name="Pheonix",
                         guid="76561198036015889")
     player.connects("1")
     self.clear_events()
     # WHEN
     self.parser.handlePacket(
         Packet.decode(
             '\x00\x05\x00\x00\x00\x08\x01\x10\x00\x01\x04\x83\xdb\x11'))
     # THEN
     self.assert_has_event("EVT_CLIENT_DISCONNECT", data='1', client=player)
Exemplo n.º 19
0
 def test_PLAYER_CHAT(self):  # 3
     # GIVEN
     player = FakeClient(self.parser,
                         name="Pheonix",
                         guid="76561198038608801")
     player.connects("1")
     self.clear_events()
     # WHEN
     self.parser.handlePacket(
         Packet.decode(
             '\x00\x03\x00\x00\x00\x17\x01\x10\x00\x01\x04\xabk\xa1\x00\x00\x00\x07 sorry \x00\x00\x00\x00'
         ))
     # THEN
     self.assert_has_event("EVT_CLIENT_SAY", data='sorry', client=player)
Exemplo n.º 20
0
 def test_unknown_msgType(self):
     # WHEN
     with patch.object(self.parser, "warning") as warning_mock:
         self.parser.handlePacket(
             Packet.decode(
                 '\x00c\x00\x00\x00\x0f\x00\x00\x00\x00I\x96\x02\xd2\x00\x00\x00\x03f00'
             ))
     # THEN
     self.assertListEqual([], self.evt_queue)
     self.assertListEqual([
         call(
             "unkown RCON message type: 99. REPORT THIS TO THE B3 FORUMS. Packet.decode('\\x00c\\x00\\x00\\x00\\x0f\\x00\\x00\\x00\\x00I\\x96\\x02\\xd2\\x00\\x00\\x00\\x03f00')  # {'msgType': 99, 'dataLength': 15, 'data': '\\x00\\x00\\x00\\x00I\\x96\\x02\\xd2\\x00\\x00\\x00\\x03f00'}"
         )
     ], warning_mock.mock_calls)
Exemplo n.º 21
0
 def test_TEAM_CHANGED_1(self):  # 13
     # GIVEN
     player = FakeClient(self.parser,
                         name="Pheonix",
                         guid="76561198070138838")
     player.connects("1")
     self.assertEqual(TEAM_UNKNOWN, player.team)
     # WHEN
     self.parser.handlePacket(
         Packet.decode(
             '\x00\r\x00\x00\x00\x0c\x01\x10\x00\x01\x06\x8c\x87\xd6\x00\x00\x00\x01'
         ))
     # THEN
     self.assertEqual(1, player.team)
Exemplo n.º 22
0
 def test_SUICIDE(self):  # 16
     # GIVEN
     poorguy = FakeClient(self.parser,
                          name="attacker_name",
                          guid='76561198070138838')
     poorguy.connects("1")
     # WHEN
     self.parser.handlePacket(
         Packet.decode(
             '\x00\x10\x00\x00\x00\x08\x01\x10\x00\x01\x06\x8c\x87\xd6'))
     # THEN
     self.assert_has_event("EVT_CLIENT_SUICIDE",
                           client=poorguy,
                           target=poorguy,
                           data=(100, None, None))
Exemplo n.º 23
0
 def test_PLAYER_CHAT_team(self):  # 3
     # GIVEN
     player = FakeClient(self.parser,
                         name="Pheonix",
                         guid="76561198038608801")
     player.connects("1")
     self.clear_events()
     player.team = 0  # ugly, until chiv team ids got converted into b3 team ids
     # WHEN
     self.parser.handlePacket(
         Packet.decode(
             '\x00\x03\x00\x00\x00\x17\x01\x10\x00\x01\x04\xabk\xa1\x00\x00\x00\x07 sorry \x00\x00\x00\x00'
         ))
     # THEN
     self.assert_has_event("EVT_CLIENT_TEAM_SAY",
                           data='sorry',
                           client=player)
Exemplo n.º 24
0
 def test_KILL(self):  # 15
     # GIVEN
     attacker = FakeClient(self.parser,
                           name="attacker_name",
                           guid='76561198036015889')
     attacker.connects("1")
     victim = FakeClient(self.parser,
                         name="victim_name",
                         guid='76561198021620061')
     victim.connects("2")
     # WHEN
     self.parser.handlePacket(
         Packet.decode(
             '\x00\x0f\x00\x00\x00\x1e\x01\x10\x00\x01\x04\x83\xdb\x11\x01\x10\x00\x01\x03\xa81]\x00\x00\x00\nTekko Kagi'
         ))
     # THEN
     self.assert_has_event("EVT_CLIENT_KILL",
                           client=attacker,
                           target=victim,
                           data=(100, u'Tekko Kagi', 'body'))