class Test_getServerInfo(BFHTestCase): def setUp(self): self.conf = CfgConfigParser() self.conf.loadFromString("""[configuration]""") self.parser = BfhParser(self.conf) self.parser.startup() def test_getServerInfo(self): # GIVEN when(self.parser).write(('serverInfo', )).thenReturn([ '[WASP] Hotwire all maps -- Working kick on kills', '0', '14', 'Hotwire0', 'MP_Eastside', '0', '2', '0', '0', '', 'true', 'true', 'false', '428710', '6019', '108.61.98.177:40000', '', 'true', 'EU', 'ams', 'NL', '0', 'IN_GAME' ]) # WHEN self.parser.getServerInfo() # THEN self.assertEqual('[WASP] Hotwire all maps -- Working kick on kills', self.parser.game.sv_hostname) self.assertEqual(14, self.parser.game.sv_maxclients) self.assertEqual("MP_Eastside", self.parser.game.mapName) self.assertEqual("Hotwire0", self.parser.game.gameType) self.assertEqual("108.61.98.177", self.parser._publicIp) self.assertEqual('40000', self.parser._gamePort) self.assertDictEqual( { 'punkBusterVersion': '', 'team2score': None, 'numPlayers': '0', 'maxPlayers': '14', 'targetScore': '0', 'closestPingSite': 'ams', 'blazeGameState': 'IN_GAME', 'onlineState': '', 'serverName': '[WASP] Hotwire all maps -- Working kick on kills', 'gamemode': 'Hotwire0', 'hasPunkbuster': 'true', 'hasPassword': '******', 'numTeams': '0', 'team1score': None, 'roundTime': '6019', 'blazePlayerCount': '0', 'isRanked': 'true', 'roundsPlayed': '0', 'serverUptime': '428710', 'team4score': None, 'level': 'MP_Eastside', 'country': 'NL', 'region': 'EU', 'joinQueueEnabled': 'true', 'roundsTotal': '2', 'gameIpAndPort': '108.61.98.177:40000', 'team3score': None }, self.parser.game.serverinfo)
class Test_getServerInfo(BFHTestCase): def setUp(self): self.conf = CfgConfigParser() self.conf.loadFromString("""[configuration]""") self.parser = BfhParser(self.conf) self.parser.startup() def test_getServerInfo(self): # GIVEN when(self.parser).write(('serverInfo',)).thenReturn([ '[WASP] Hotwire all maps -- Working kick on kills', '0', '14', 'Hotwire0', 'MP_Eastside', '0', '2', '0', '0', '', 'true', 'true', 'false', '428710', '6019', '108.61.98.177:40000', '', 'true', 'EU', 'ams', 'NL', '0', 'IN_GAME' ]) # WHEN self.parser.getServerInfo() # THEN self.assertEqual('[WASP] Hotwire all maps -- Working kick on kills', self.parser.game.sv_hostname) self.assertEqual(14, self.parser.game.sv_maxclients) self.assertEqual("MP_Eastside", self.parser.game.mapName) self.assertEqual("Hotwire0", self.parser.game.gameType) self.assertEqual("108.61.98.177", self.parser._publicIp) self.assertEqual('40000', self.parser._gamePort) self.assertDictEqual( {'punkBusterVersion': '', 'team2score': None, 'numPlayers': '0', 'maxPlayers': '14', 'targetScore': '0', 'closestPingSite': 'ams', 'blazeGameState': 'IN_GAME', 'onlineState': '', 'serverName': '[WASP] Hotwire all maps -- Working kick on kills', 'gamemode': 'Hotwire0', 'hasPunkbuster': 'true', 'hasPassword': '******', 'numTeams': '0', 'team1score': None, 'roundTime': '6019', 'blazePlayerCount': '0', 'isRanked': 'true', 'roundsPlayed': '0', 'serverUptime': '428710', 'team4score': None, 'level': 'MP_Eastside', 'country': 'NL', 'region': 'EU', 'joinQueueEnabled': 'true', 'roundsTotal': '2', 'gameIpAndPort': '108.61.98.177:40000', 'team3score': None}, self.parser.game.serverinfo)
class Test_bfh_sends_no_guid(BFHTestCase): """ See bug https://github.com/thomasleveil/big-brother-bot/issues/69 """ def setUp(self): BFHTestCase.setUp(self) self.conf = XmlConfigParser() self.conf.loadFromString("<configuration/>") self.parser = BfhParser(self.conf) self.parser.startup() self.authorizeClients_patcher = patch.object(self.parser.clients, "authorizeClients") self.authorizeClients_patcher.start() self.write_patcher = patch.object(self.parser, "write") self.write_mock = self.write_patcher.start() self.event_raw_data = 'PunkBuster Server: 14 300000aaaaaabbbbbbccccc111223300(-) 11.122.103.24:3659 OK 1 3.0 0 (W) "Snoopy"' self.regex_for_OnPBPlistItem = [ x for (x, y) in self.parser._punkbusterMessageFormats if y == 'OnPBPlistItem' ][0] def tearDown(self): BFHTestCase.tearDown(self) self.authorizeClients_patcher.stop() self.write_mock = self.write_patcher.stop() def test_auth_client_without_guid_but_with_known_pbid(self): # GIVEN # known superadmin named Snoopy superadmin = Client(console=self.parser, name='Snoopy', guid='EA_AAAAAAAABBBBBBBBBBBBBB00000000000012222', pbid='300000aaaaaabbbbbbccccc111223300', group_bits=128, connections=21) superadmin.save() # bf3 server failing to provide guid def write(data): if data == ('admin.listPlayers', 'player', 'Snoopy'): return [ '7', 'name', 'guid', 'teamId', 'squadId', 'kills', 'deaths', 'score', '1', 'Snoopy', '', '2', '8', '0', '0', '0' ] else: return DEFAULT self.write_mock.side_effect = write # WHEN self.assertFalse('Snoopy' in self.parser.clients) self.parser.OnPBPlayerGuid(match=re.match(self.regex_for_OnPBPlistItem, self.event_raw_data), data=self.event_raw_data) # THEN # B3 should have authed Snoopy self.assertTrue('Snoopy' in self.parser.clients) snoopy = self.parser.clients['Snoopy'] self.assertTrue(snoopy.authed) for attb in ('name', 'pbid', 'guid', 'groupBits'): self.assertEqual(getattr(superadmin, attb), getattr(snoopy, attb)) def test_does_not_auth_client_without_guid_and_unknown_pbid(self): # GIVEN # bf3 server failing to provide guid def write(data): if data == ('admin.listPlayers', 'player', 'Snoopy'): return [ '7', 'name', 'guid', 'teamId', 'squadId', 'kills', 'deaths', 'score', '1', 'Snoopy', '', '2', '8', '0', '0', '0' ] else: return DEFAULT self.write_mock.side_effect = write # WHEN self.assertFalse('Snoopy' in self.parser.clients) self.parser.OnPBPlayerGuid(match=re.match(self.regex_for_OnPBPlistItem, self.event_raw_data), data=self.event_raw_data) # THEN # B3 should have authed Snoopy self.assertTrue('Snoopy' in self.parser.clients) snoopy = self.parser.clients['Snoopy'] self.assertFalse(snoopy.authed)
class Test_punkbuster_events(BFHTestCase): def setUp(self): self.conf = XmlConfigParser() self.conf.loadFromString(""" <configuration> </configuration> """) self.parser = BfhParser(self.conf) self.parser.startup() def pb(self, msg): return self.parser.OnPunkbusterMessage(action=None, data=[msg]) def assert_pb_misc_evt(self, msg): assert str(self.pb(msg)).startswith('Event<EVT_PUNKBUSTER_MISC>') def test_PB_SV_BanList(self): self.assert_pb_misc_evt( 'PunkBuster Server: 1 b59ffffffffffffffffffffffffffc7d {13/15} "Cucurbitaceae" "87.45.14.2:3659" retest" ""' ) self.assert_pb_misc_evt( 'PunkBuster Server: 1 b59ffffffffffffffffffffffffffc7d {0/1440} "Cucurbitaceae" "87.45.14.2:3659" mlkjsqfd" ""' ) self.assertEquals( '''Event<EVT_PUNKBUSTER_UNKNOWN>(['PunkBuster Server: 1 (UnBanned) b59ffffffffffffffffffffffffffc7d {15/15} "Cucurbitaceae" "87.45.14.2:3659" retest" ""'], None, None)''', str( self. pb('PunkBuster Server: 1 (UnBanned) b59ffffffffffffffffffffffffffc7d {15/15} "Cucurbitaceae" "87.45.14.2:3659" retest" ""' ))) self.assert_pb_misc_evt( 'PunkBuster Server: Guid=b59ffffffffffffffffffffffffffc7d" Not Found in the Ban List' ) self.assert_pb_misc_evt( 'PunkBuster Server: End of Ban List (1 of 1 displayed)') def test_PB_UCON_message(self): result = self.pb( 'PunkBuster Server: PB UCON "ggc_85.214.107.154"@85.214.107.154:14516 [admin.say "GGC-Stream.com - Welcome Cucurbitaceae with the GUID 31077c7d to our server." all]\n' ) self.assertEqual( 'Event<EVT_PUNKBUSTER_UCON>({\'ip\': \'85.214.107.154\', \'cmd\': \'admin.say "GGC-Stream.com - Welcome Cucurbitaceae with the GUID 31077c7d to our server." all\', \'from\': \'ggc_85.214.107.154\', \'port\': \'14516\'}, None, None)', str(result)) def test_PB_Screenshot_received_message(self): result = self.pb( 'PunkBuster Server: Screenshot C:\\games\\bf3\\173_199_73_213_25200\\862147\\bf3\\pb\\svss\\pb000709.png successfully received (MD5=4576546546546546546546546543E1E1) from 19 Jaffar [da876546546546546546546546547673(-) 111.22.33.111:3659]\n' ) self.assertEqual( r"Event<EVT_PUNKBUSTER_SCREENSHOT_RECEIVED>({'slot': '19', 'name': 'Jaffar', 'ip': '111.22.33.111', 'pbid': 'da876546546546546546546546547673', 'imgpath': 'C:\\games\\bf3\\173_199_73_213_25200\\862147\\bf3\\pb\\svss\\pb000709.png', 'port': '3659', 'md5': '4576546546546546546546546543E1E1'}, None, None)", str(result)) def test_PB_SV_PList(self): self.assert_pb_misc_evt( "PunkBuster Server: Player List: [Slot #] [GUID] [Address] [Status] [Power] [Auth Rate] [Recent SS] [O/S] [Name]" ) self.assert_pb_misc_evt( 'PunkBuster Server: End of Player List (0 Players)') def test_PB_Ver(self): self.assertIsNone( self. pb('PunkBuster Server: PunkBuster Server for BFH (v1.839 | A1386 C2.279) Enabled\n' )) def test_PB_SV_BanGuid(self): self.assert_pb_misc_evt('PunkBuster Server: Ban Added to Ban List') self.assert_pb_misc_evt('PunkBuster Server: Ban Failed') def test_PB_SV_UnBanGuid(self): self.assert_pb_misc_evt( 'PunkBuster Server: Guid b59f190e5ef725e06531387231077c7d has been Unbanned' ) def test_PB_SV_UpdBanFile(self): self.assert_pb_misc_evt( "PunkBuster Server: 0 Ban Records Updated in d:\\localuser\\g119142\\pb\\pbbans.dat" ) def test_misc(self): self.assertEqual( "Event<EVT_PUNKBUSTER_LOST_PLAYER>({'slot': '1', 'ip': 'x.x.x.x', 'port': '3659', 'name': 'joe', 'pbuid': '0837c128293d42aaaaaaaaaaaaaaaaa'}, None, None)", str( self. pb("PunkBuster Server: Lost Connection (slot #1) x.x.x.x:3659 0837c128293d42aaaaaaaaaaaaaaaaa(-) joe" ))) self.assert_pb_misc_evt( "PunkBuster Server: Invalid Player Specified: None") self.assert_pb_misc_evt( "PunkBuster Server: Matched: Cucurbitaceae (slot #1)") self.assert_pb_misc_evt( "PunkBuster Server: Received Master Security Information") self.assert_pb_misc_evt( "PunkBuster Server: Auto Screenshot 000714 Requested from 25 Goldbat" )
class Test_bfh_events(BFHTestCase): def setUp(self): self.conf = CfgConfigParser() self.conf.loadFromString("""[configuration]""") self.parser = BfhParser(self.conf) self.parser.startup() # mock parser queueEvent method so we can make assertions on it later on self.parser.queueEvent = Mock(name="queueEvent method") self.joe = Mock(name="Joe", spec=Client) def event_repr(self): return "Event(%r, data=%r, client=%r, target=%r)" % ( b3.events.eventManager.getName( self.type), self.data, self.client, self.target) b3.events.Event.__repr__ = event_repr def test_cmd_rotateMap_generates_EVT_GAME_ROUND_END(self): # prepare fake BFH server responses def fake_write(data): if data == ('mapList.getMapIndices', ): return [0, 1] else: return [] self.parser.write = Mock(side_effect=fake_write) self.parser.getFullMapRotationList = Mock(return_value=MapListBlock([ '4', '3', 'MP_007', 'RushLarge0', '4', 'MP_011', 'RushLarge0', '4', 'MP_012', 'SquadRush0', '4', 'MP_013', 'SquadRush0', '4' ])) self.parser.rotateMap() self.assertEqual(1, self.parser.queueEvent.call_count) self.assertEqual(self.parser.getEventID("EVT_GAME_ROUND_END"), self.parser.queueEvent.call_args[0][0].type) self.assertIsNone(self.parser.queueEvent.call_args[0][0].data) def test_player_onChat_event_all(self): self.parser.getClient = Mock(return_value=self.joe) self.parser.routeFrostbitePacket( ['player.onChat', 'Cucurbitaceae', 'test all', 'all']) self.assertEqual(1, self.parser.queueEvent.call_count) event = self.parser.queueEvent.call_args[0][0] self.assertEqual("Say", self.parser.getEventName(event.type)) self.assertEquals('test all', event.data) self.assertEqual(self.joe, event.client) def test_player_onChat_event_team(self): self.parser.getClient = Mock(return_value=self.joe) self.parser.routeFrostbitePacket( ['player.onChat', 'Cucurbitaceae', 'test team', 'team', '1']) self.assertEqual(1, self.parser.queueEvent.call_count) event = self.parser.queueEvent.call_args[0][0] self.assertEqual("Team Say", self.parser.getEventName(event.type)) self.assertEquals('test team', event.data) self.assertEqual(self.joe, event.client) def test_player_onChat_event_squad(self): self.parser.getClient = Mock(return_value=self.joe) self.parser.routeFrostbitePacket([ 'player.onChat', 'Cucurbitaceae', 'test squad', 'squad', '1', '1' ]) self.assertEqual(1, self.parser.queueEvent.call_count) event = self.parser.queueEvent.call_args[0][0] self.assertEqual("Squad Say", self.parser.getEventName(event.type)) self.assertEquals('test squad', event.data) self.assertEqual(self.joe, event.client) def test_server_onLevelLoaded(self): # GIVEN when(self.parser).write(('serverInfo', )).thenReturn([ '[WASP] Hotwire all maps -- Working kick on kills', '0', '14', 'Hotwire0', 'MP_Eastside', '0', '2', '0', '0', '', 'true', 'true', 'false', '428710', '6019', '108.61.98.177:40000', '', 'true', 'EU', 'ams', 'NL', '0', 'IN_GAME' ]) # WHEN with patch.object(self.parser, "warning") as warning_mock: self.parser.routeFrostbitePacket([ 'server.onLevelLoaded', 'MP_Glades', 'TeamDeathMatch0', '0', '1' ]) # THEN event = self.parser.queueEvent.call_args[0][0] self.assertEqual('Game Warmup', self.parser.getEventName(event.type)) self.assertEquals('MP_Glades', event.data) self.assertListEqual([], warning_mock.mock_calls)
class Test_bfh_sends_no_guid(BFHTestCase): """ See bug https://github.com/thomasleveil/big-brother-bot/issues/69 """ def setUp(self): BFHTestCase.setUp(self) self.conf = XmlConfigParser() self.conf.loadFromString("<configuration/>") self.parser = BfhParser(self.conf) self.parser.startup() self.authorizeClients_patcher = patch.object(self.parser.clients, "authorizeClients") self.authorizeClients_patcher.start() self.write_patcher = patch.object(self.parser, "write") self.write_mock = self.write_patcher.start() self.event_raw_data = 'PunkBuster Server: 14 300000aaaaaabbbbbbccccc111223300(-) 11.122.103.24:3659 OK 1 3.0 0 (W) "Snoopy"' self.regex_for_OnPBPlistItem = [x for (x, y) in self.parser._punkbusterMessageFormats if y == 'OnPBPlistItem'][ 0] def tearDown(self): BFHTestCase.tearDown(self) self.authorizeClients_patcher.stop() self.write_mock = self.write_patcher.stop() def test_auth_client_without_guid_but_with_known_pbid(self): # GIVEN # known superadmin named Snoopy superadmin = Client(console=self.parser, name='Snoopy', guid='EA_AAAAAAAABBBBBBBBBBBBBB00000000000012222', pbid='300000aaaaaabbbbbbccccc111223300', group_bits=128, connections=21) superadmin.save() # bf3 server failing to provide guid def write(data): if data == ('admin.listPlayers', 'player', 'Snoopy'): return ['7', 'name', 'guid', 'teamId', 'squadId', 'kills', 'deaths', 'score', '1', 'Snoopy', '', '2', '8', '0', '0', '0'] else: return DEFAULT self.write_mock.side_effect = write # WHEN self.assertFalse('Snoopy' in self.parser.clients) self.parser.OnPBPlayerGuid(match=re.match(self.regex_for_OnPBPlistItem, self.event_raw_data), data=self.event_raw_data) # THEN # B3 should have authed Snoopy self.assertTrue('Snoopy' in self.parser.clients) snoopy = self.parser.clients['Snoopy'] self.assertTrue(snoopy.authed) for attb in ('name', 'pbid', 'guid', 'groupBits'): self.assertEqual(getattr(superadmin, attb), getattr(snoopy, attb)) def test_does_not_auth_client_without_guid_and_unknown_pbid(self): # GIVEN # bf3 server failing to provide guid def write(data): if data == ('admin.listPlayers', 'player', 'Snoopy'): return ['7', 'name', 'guid', 'teamId', 'squadId', 'kills', 'deaths', 'score', '1', 'Snoopy', '', '2', '8', '0', '0', '0'] else: return DEFAULT self.write_mock.side_effect = write # WHEN self.assertFalse('Snoopy' in self.parser.clients) self.parser.OnPBPlayerGuid(match=re.match(self.regex_for_OnPBPlistItem, self.event_raw_data), data=self.event_raw_data) # THEN # B3 should have authed Snoopy self.assertTrue('Snoopy' in self.parser.clients) snoopy = self.parser.clients['Snoopy'] self.assertFalse(snoopy.authed)
class Test_punkbuster_events(BFHTestCase): def setUp(self): self.conf = XmlConfigParser() self.conf.loadFromString(""" <configuration> </configuration> """) self.parser = BfhParser(self.conf) self.parser.startup() def pb(self, msg): return self.parser.OnPunkbusterMessage(action=None, data=[msg]) def assert_pb_misc_evt(self, msg): assert str(self.pb(msg)).startswith('Event<EVT_PUNKBUSTER_MISC>') def test_PB_SV_BanList(self): self.assert_pb_misc_evt( 'PunkBuster Server: 1 b59ffffffffffffffffffffffffffc7d {13/15} "Cucurbitaceae" "87.45.14.2:3659" retest" ""') self.assert_pb_misc_evt( 'PunkBuster Server: 1 b59ffffffffffffffffffffffffffc7d {0/1440} "Cucurbitaceae" "87.45.14.2:3659" mlkjsqfd" ""') self.assertEquals( '''Event<EVT_PUNKBUSTER_UNKNOWN>(['PunkBuster Server: 1 (UnBanned) b59ffffffffffffffffffffffffffc7d {15/15} "Cucurbitaceae" "87.45.14.2:3659" retest" ""'], None, None)''', str(self.pb( 'PunkBuster Server: 1 (UnBanned) b59ffffffffffffffffffffffffffc7d {15/15} "Cucurbitaceae" "87.45.14.2:3659" retest" ""'))) self.assert_pb_misc_evt('PunkBuster Server: Guid=b59ffffffffffffffffffffffffffc7d" Not Found in the Ban List') self.assert_pb_misc_evt('PunkBuster Server: End of Ban List (1 of 1 displayed)') def test_PB_UCON_message(self): result = self.pb( 'PunkBuster Server: PB UCON "ggc_85.214.107.154"@85.214.107.154:14516 [admin.say "GGC-Stream.com - Welcome Cucurbitaceae with the GUID 31077c7d to our server." all]\n') self.assertEqual( 'Event<EVT_PUNKBUSTER_UCON>({\'ip\': \'85.214.107.154\', \'cmd\': \'admin.say "GGC-Stream.com - Welcome Cucurbitaceae with the GUID 31077c7d to our server." all\', \'from\': \'ggc_85.214.107.154\', \'port\': \'14516\'}, None, None)', str(result)) def test_PB_Screenshot_received_message(self): result = self.pb( 'PunkBuster Server: Screenshot C:\\games\\bf3\\173_199_73_213_25200\\862147\\bf3\\pb\\svss\\pb000709.png successfully received (MD5=4576546546546546546546546543E1E1) from 19 Jaffar [da876546546546546546546546547673(-) 111.22.33.111:3659]\n') self.assertEqual( r"Event<EVT_PUNKBUSTER_SCREENSHOT_RECEIVED>({'slot': '19', 'name': 'Jaffar', 'ip': '111.22.33.111', 'pbid': 'da876546546546546546546546547673', 'imgpath': 'C:\\games\\bf3\\173_199_73_213_25200\\862147\\bf3\\pb\\svss\\pb000709.png', 'port': '3659', 'md5': '4576546546546546546546546543E1E1'}, None, None)", str(result)) def test_PB_SV_PList(self): self.assert_pb_misc_evt( "PunkBuster Server: Player List: [Slot #] [GUID] [Address] [Status] [Power] [Auth Rate] [Recent SS] [O/S] [Name]") self.assert_pb_misc_evt('PunkBuster Server: End of Player List (0 Players)') def test_PB_Ver(self): self.assertIsNone(self.pb('PunkBuster Server: PunkBuster Server for BFH (v1.839 | A1386 C2.279) Enabled\n')) def test_PB_SV_BanGuid(self): self.assert_pb_misc_evt('PunkBuster Server: Ban Added to Ban List') self.assert_pb_misc_evt('PunkBuster Server: Ban Failed') def test_PB_SV_UnBanGuid(self): self.assert_pb_misc_evt('PunkBuster Server: Guid b59f190e5ef725e06531387231077c7d has been Unbanned') def test_PB_SV_UpdBanFile(self): self.assert_pb_misc_evt("PunkBuster Server: 0 Ban Records Updated in d:\\localuser\\g119142\\pb\\pbbans.dat") def test_misc(self): self.assertEqual( "Event<EVT_PUNKBUSTER_LOST_PLAYER>({'slot': '1', 'ip': 'x.x.x.x', 'port': '3659', 'name': 'joe', 'pbuid': '0837c128293d42aaaaaaaaaaaaaaaaa'}, None, None)", str(self.pb( "PunkBuster Server: Lost Connection (slot #1) x.x.x.x:3659 0837c128293d42aaaaaaaaaaaaaaaaa(-) joe"))) self.assert_pb_misc_evt("PunkBuster Server: Invalid Player Specified: None") self.assert_pb_misc_evt("PunkBuster Server: Matched: Cucurbitaceae (slot #1)") self.assert_pb_misc_evt("PunkBuster Server: Received Master Security Information") self.assert_pb_misc_evt("PunkBuster Server: Auto Screenshot 000714 Requested from 25 Goldbat")
class Test_bfh_events(BFHTestCase): def setUp(self): self.conf = CfgConfigParser() self.conf.loadFromString("""[configuration]""") self.parser = BfhParser(self.conf) self.parser.startup() # mock parser queueEvent method so we can make assertions on it later on self.parser.queueEvent = Mock(name="queueEvent method") self.joe = Mock(name="Joe", spec=Client) def event_repr(self): return "Event(%r, data=%r, client=%r, target=%r)" % (b3.events.eventManager.getName(self.type), self.data, self.client, self.target) b3.events.Event.__repr__ = event_repr def test_cmd_rotateMap_generates_EVT_GAME_ROUND_END(self): # prepare fake BFH server responses def fake_write(data): if data == ('mapList.getMapIndices', ): return [0, 1] else: return [] self.parser.write = Mock(side_effect=fake_write) self.parser.getFullMapRotationList = Mock(return_value=MapListBlock( ['4', '3', 'MP_007', 'RushLarge0', '4', 'MP_011', 'RushLarge0', '4', 'MP_012', 'SquadRush0', '4', 'MP_013', 'SquadRush0', '4'])) self.parser.rotateMap() self.assertEqual(1, self.parser.queueEvent.call_count) self.assertEqual(self.parser.getEventID("EVT_GAME_ROUND_END"), self.parser.queueEvent.call_args[0][0].type) self.assertIsNone(self.parser.queueEvent.call_args[0][0].data) def test_player_onChat_event_all(self): self.parser.getClient = Mock(return_value=self.joe) self.parser.routeFrostbitePacket(['player.onChat', 'Cucurbitaceae', 'test all', 'all']) self.assertEqual(1, self.parser.queueEvent.call_count) event = self.parser.queueEvent.call_args[0][0] self.assertEqual("Say", self.parser.getEventName(event.type)) self.assertEquals('test all', event.data) self.assertEqual(self.joe, event.client) def test_player_onChat_event_team(self): self.parser.getClient = Mock(return_value=self.joe) self.parser.routeFrostbitePacket(['player.onChat', 'Cucurbitaceae', 'test team', 'team', '1']) self.assertEqual(1, self.parser.queueEvent.call_count) event = self.parser.queueEvent.call_args[0][0] self.assertEqual("Team Say", self.parser.getEventName(event.type)) self.assertEquals('test team', event.data) self.assertEqual(self.joe, event.client) def test_player_onChat_event_squad(self): self.parser.getClient = Mock(return_value=self.joe) self.parser.routeFrostbitePacket(['player.onChat', 'Cucurbitaceae', 'test squad', 'squad', '1', '1']) self.assertEqual(1, self.parser.queueEvent.call_count) event = self.parser.queueEvent.call_args[0][0] self.assertEqual("Squad Say", self.parser.getEventName(event.type)) self.assertEquals('test squad', event.data) self.assertEqual(self.joe, event.client) def test_server_onLevelLoaded(self): # GIVEN when(self.parser).write(('serverInfo',)).thenReturn([ '[WASP] Hotwire all maps -- Working kick on kills', '0', '14', 'Hotwire0', 'MP_Eastside', '0', '2', '0', '0', '', 'true', 'true', 'false', '428710', '6019', '108.61.98.177:40000', '', 'true', 'EU', 'ams', 'NL', '0', 'IN_GAME']) # WHEN with patch.object(self.parser, "warning") as warning_mock: self.parser.routeFrostbitePacket(['server.onLevelLoaded', 'MP_Glades', 'TeamDeathMatch0', '0', '1']) # THEN event = self.parser.queueEvent.call_args[0][0] self.assertEqual('Game Warmup', self.parser.getEventName(event.type)) self.assertEquals('MP_Glades', event.data) self.assertListEqual([], warning_mock.mock_calls)