def test_getPlayerList(self): """ Query the game server for connected players. return a dict having players' id for keys and players' data as another dict for values """ when(self.output_mock).write('status', maxRetries=anything()).thenReturn(""" map: ut4_casa num score ping name lastmsg address qport rate --- ----- ---- --------------- ------- --------------------- ----- ----- 10 0 13 snowwhite 0 192.168.1.11:51034 9992 15000 12 0 10 superman 0 192.168.1.12:53039 9993 15000 """) result = self.console.getPlayerList() verify(self.output_mock).write('status', maxRetries=anything()) self.assertDictEqual({'10': {'ip': '192.168.1.11', 'last': '0', 'name': 'snowwhite', 'pbid': None, 'ping': '13', 'port': '51034', 'qport': '9992', 'rate': '15000', 'score': '0', 'slot': '10'}, '12': {'ip': '192.168.1.12', 'last': '0', 'name': 'superman', 'pbid': None, 'ping': '10', 'port': '53039', 'qport': '9993', 'rate': '15000', 'score': '0', 'slot': '12'}} , result)
def test_getMaps(self): """ return the available maps/levels name """ when(self.output_mock).write('fdir *.bsp', socketTimeout=anything()).thenReturn("""\ --------------- maps/ut4_abbey.bsp maps/ut4_algiers.bsp maps/ut4_austria.bsp maps/ut4_casa.bsp """) maps = self.console.getMaps() verify(self.output_mock).write('fdir *.bsp', socketTimeout=anything()) self.assertSetEqual({'ut4_abbey', 'ut4_algiers', 'ut4_austria', 'ut4_casa'}, set(maps))
def test_getPlayerList_without_punkbuster(self): # See http://forum.bigbrotherbot.net/general-discussion/%27bug%27-in-cod4parser/msg38165/ # See http://forum.bigbrotherbot.net/general-usage-support/b3-not-authenticate/msg38262/ # GIVEN self.console.PunkBuster = None when(self.console).write('status', maxRetries=anything()).thenReturn('''\ map: mp_backlot num score ping guid name lastmsg address qport rate --- ----- ---- -------------------------------- --------------- ------- --------------------- ----- ----- 0 0 14 1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaab player1^7 0 11.22.33.44:-6187 -1609 25000 1 0 12 1ccccccccccccccccccccccccccccccc player2^7 0 22.33.44.55:-10803-23569 25000 3 486 185 ecc77e3400a38cc71b3849207e20e1b0 GO_NINJA^7 0 111.222.111.111:-15535-2655 25000 5 92 509 0123456789abcdef0123456789abcdef 7ajimaki^7 100 11.222.111.44:28960 -27329 25000 6 0 206 0123456789a654654646545789abcdef [NRNS]ArmedGuy^7 0 11.22.111.44:28960 -21813 25000 7 30 229 012343213211313213321313131bcdef Franco^7 0 111.22.111.111:23144 22922 25000 8 0 110 a630006508000000000000000011d9a2 Badschga2002^7 0 11.11.11.6328960 -21738 25000 ''') # WHEN rv = self.console.getPlayerList() # THEN self.assertDictEqual({'slot': '0', 'score': '0', 'ping': '14', 'guid': '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', 'name': 'player1^7', 'last': '0', 'ip': '11.22.33.44', 'port': '-6187', 'qport': '-1609', 'rate': '25000', 'pbid': None}, rv.get("0", {}), rv) self.assertDictEqual({'slot': '1', 'score': '0', 'ping': '12', 'guid': '1ccccccccccccccccccccccccccccccc', 'name': 'player2^7', 'last': '0', 'ip': '22.33.44.55', 'port': '-10803', 'qport': '-23569', 'rate': '25000', 'pbid': None}, rv.get("1", {}), rv) self.assertDictEqual({'slot': '3', 'score': '486', 'ping': '185', 'guid': 'ecc77e3400a38cc71b3849207e20e1b0', 'name': 'GO_NINJA^7', 'last': '0', 'ip': '111.222.111.111', 'port': '-15535', 'qport': '-2655', 'rate': '25000', 'pbid': None}, rv.get("3", {}), rv) self.assertDictEqual({'slot': '5', 'score': '92', 'ping': '509', 'guid': '0123456789abcdef0123456789abcdef', 'name': '7ajimaki^7', 'last': '100', 'ip': '11.222.111.44', 'port': '28960', 'qport': '-27329', 'rate': '25000', 'pbid': None}, rv.get("5", {}), rv) self.assertDictEqual({'slot': '6', 'score': '0', 'ping': '206', 'guid': '0123456789a654654646545789abcdef', 'name': '[NRNS]ArmedGuy^7', 'last': '0', 'ip': '11.22.111.44', 'port': '28960', 'qport': '-21813', 'rate': '25000', 'pbid': None}, rv.get("6", {}), rv) self.assertDictEqual({'slot': '7', 'score': '30', 'ping': '229', 'guid': '012343213211313213321313131bcdef', 'name': 'Franco^7', 'last': '0', 'ip': '111.22.111.111', 'port': '23144', 'qport': '22922', 'rate': '25000', 'pbid': None}, rv.get("7", {}), rv) self.assertDictEqual({'slot': '8', 'score': '0', 'ping': '110', 'guid': 'a630006508000000000000000011d9a2', 'name': 'Badschga2002^7', 'last': '0', 'ip': '11.11.11.63', 'port': '28960', 'qport': '-21738', 'rate': '25000', 'pbid': None}, rv.get("8", {}), rv)
def test_getPlayerList_without_punkbuster(self): # GIVEN self.console.PunkBuster = None when(self.console).write('status', maxRetries=anything()).thenReturn('''\ map: mp_villa num score ping guid name lastmsg address qport rate --- ----- ---- ---------- --------------- ------- --------------------- ------ ----- 0 0 0 0 democlient^7 1650 unknown 1773 5000 1 0 55 63281996 BandAid^7 50 11.11.11.11:524 8045 25000 2 0 157 81554346 hugobongenhielm^7 50 11.11.11.11:524 22481 25000 3 0 156 86330555 Irish^7 0 11.11.11.11:9162 14288 25000 4 0 999 68003079 Ashhole^7 750 11.11.11.11:19978 19033 25000 5 5 53 318670 bigredtwit^7 011.11.11.11:28966 1259 25000 ''') # WHEN rv = self.console.getPlayerList() # THEN self.assertDictContainsSubset({ 'slot': '1', 'score': '0', 'ping': '55', 'guid': '63281996', 'name': 'BandAid^7', 'last': '50', 'ip': '11.11.11.11', 'pbid': None }, rv.get('1', {}), rv) self.assertDictContainsSubset({ 'slot': '2', 'score': '0', 'ping': '157', 'guid': '81554346', 'name': 'hugobongenhielm^7', 'last': '50', 'ip': '11.11.11.11', 'pbid': None }, rv.get('2', {}), rv) self.assertDictContainsSubset({ 'slot': '3', 'score': '0', 'ping': '156', 'guid': '86330555', 'name': 'Irish^7', 'last': '0', 'ip': '11.11.11.11', 'pbid': None }, rv.get('3', {}), rv) self.assertDictContainsSubset({ 'slot': '4', 'score': '0', 'ping': '999', 'guid': '68003079', 'name': 'Ashhole^7', 'last': '750', 'ip': '11.11.11.11', 'pbid': None }, rv.get('4', {}), rv) self.assertDictContainsSubset({ 'slot': '5', 'score': '5', 'ping': '53', 'guid': '318670', 'name': 'bigredtwit^7', 'last': '0', 'ip': '11.11.11.11', 'pbid': None }, rv.get('5', {}), rv)
def test_sync(self): # GIVEN when(self.console).write('status', maxRetries=anything()).thenReturn('''\ map: ut4_casa num score ping name lastmsg address qport rate --- ----- ---- --------------- ------- --------------------- ----- ----- 0 0 48 laCourge^7 0 11.22.33.44:27961 13492 16000 ''') when(self.console).write('dumpuser 0').thenReturn('''\ userinfo -------- ip 11.22.33.44:27961 name laCourge cl_guid 00000000000000014111111111111111 ''') when(self.console).write('auth-whois 0').thenReturn('''\ auth: id: 0 - name: ^7laCourge - login: courgette - notoriety: serious - level: -1 ''') # WHEN mlist = self.console.sync() # THEN self.assertIn("0", mlist) player = mlist.get("0", None) self.assertIsNotNone(player) self.assertEqual('00000000000000014111111111111111', player.guid) self.assertEqual('courgette', player.pbid) self.assertTrue(player.authed)
def test_getPlayerList_without_punkbuster(self): # GIVEN self.console.PunkBuster = None when(self.console).write('status', maxRetries=anything()).thenReturn('''\ map: mp_highrise num score ping guid name lastmsg address qport rate --- ----- ---- -------------------------------- --------------- ------- --------------------- ----- ----- 0 1 69 011000010002d113 Minikruku!^7 0 11.11.11.11:16864 20125 25000 1 1 101 011000010002caf1 GuMaK111^7 50 11.11.11.11:4294934838 690 25000 2 1 175 0110000100003fb4 phantom1151^7 0 11.11.11.11:28960 10929 25000 3 1 49 011000010003ed88 isidora10^7 0 11.11.11.11:429496262727388 25000 4 1 31 011000018e87f252 [^5RnK^0] ^4B^7 50 11.11.11.11:28960 26213 25000 ''') # WHEN rv = self.console.getPlayerList() # THEN self.assertDictContainsSubset({ 'slot': '0', 'score': '1', 'ping': '69', 'guid': '011000010002d113', 'name': 'Minikruku!^7', 'last': '0', 'ip': '11.11.11.11', 'pbid': None }, rv.get('0', {})) self.assertDictContainsSubset({ 'slot': '1', 'score': '1', 'ping': '101', 'guid': '011000010002caf1', 'name': 'GuMaK111^7', 'last': '50', 'ip': '11.11.11.11', 'pbid': None }, rv.get('1', {})) self.assertDictContainsSubset({ 'slot': '2', 'score': '1', 'ping': '175', 'guid': '0110000100003fb4', 'name': 'phantom1151^7', 'last': '0', 'ip': '11.11.11.11', 'pbid': None }, rv.get('2', {})) self.assertDictContainsSubset({ 'slot': '3', 'score': '1', 'ping': '49', 'guid': '011000010003ed88', 'name': 'isidora10^7', 'last': '0', 'ip': '11.11.11.11', 'pbid': None }, rv.get('3', {})) self.assertDictContainsSubset({ 'slot': '4', 'score': '1', 'ping': '31', 'guid': '011000018e87f252', 'name': '[^5RnK^0] ^4B^7', 'last': '50', 'ip': '11.11.11.11', 'pbid': None }, rv.get('4', {}))
def test_getPlayerList_without_punkbuster(self): # GIVEN self.console.PunkBuster = None when(self.console).write('status', maxRetries=anything()).thenReturn(""" map: mp_backlot num score ping guid name lastmsg address qport rate --- ----- ---- -------------------------------- --------------- ------- --------------------- ----- ----- 0 0 3 GameRanger-Account-ID_0006400896 Ranger^7 50 103.231.162.141:16000 7068 25000 """) # WHEN rv = self.console.getPlayerList() # THEN self.assertDictEqual( { 'slot': '0', 'score': '0', 'ping': '3', 'guid': '0006400896', 'name': 'Ranger^7', 'last': '50', 'ip': '103.231.162.141', 'port': '16000', 'qport': '7068', 'rate': '25000', 'pbid': None }, rv.get("0", {}), rv)
def test_getPlayerList_without_punkbuster(self): # GIVEN self.console.PunkBuster = None when(self.console).write('status', maxRetries=anything()).thenReturn('''\ map: mp_stadium num score ping guid name lastmsg address qport rate --- ----- ---- ---------- --------------- ------- --------------------- ------ ----- 0 0 0 0 democlient^7 362150 unknown 1773 5000 1 200 47 8326146 ShaGGyTuBBs^7 0 11.11.11.11:524 16783 25000 2 1360 61 56089378 fresh breeze^7 0 11.11.11.11:-27409 -7422 25000 3 470 97 69406003 kossi__86^7 0 11.11.11.11:524 -24017 25000 ''') # WHEN rv = self.console.getPlayerList() # THEN self.assertNotIn("0", rv) self.assertDictContainsSubset( { 'slot': '1', 'score': '200', 'ping': '47', 'guid': '8326146', 'name': 'ShaGGyTuBBs^7', 'last': '0', 'ip': '11.11.11.11', 'port': '524', 'qport': '16783', 'rate': '25000', 'pbid': None }, rv.get("1", {})) self.assertDictContainsSubset( { 'slot': '2', 'score': '1360', 'ping': '61', 'guid': '56089378', 'name': 'fresh breeze^7', 'last': '0', 'ip': '11.11.11.11', 'port': '-27409', 'qport': '7422', 'rate': '25000', 'pbid': None }, rv.get("2", {})) self.assertDictContainsSubset( { 'slot': '3', 'score': '470', 'ping': '97', 'guid': '69406003', 'name': 'kossi__86^7', 'last': '0', 'ip': '11.11.11.11', 'port': '524', 'qport': '24017', 'rate': '25000', 'pbid': None }, rv.get("3", {}))
def test__checkClient__error(self): # GIVEN when(self.p)._query_service(anything()).thenRaise(NotImplementedError('foo')) self.joe.connects("slot1") # WHEN with patch.object(self.p, "_takeActionAgainst") as mock_takeActionAgainst: self.p._checkClient(self.joe) # THEN self.assertEqual(0, mock_takeActionAgainst.call_count)
def test_authorizeClients(self): """ For all connected players, fill the client object with properties allowing to find the user in the database (usualy guid, or punkbuster id, ip) and call the Client.auth() method """ superman = mock() self.console.clients = mock() when(self.console.clients).getByCID("12").thenReturn(superman) when(self.output_mock).write('status', maxRetries=anything()).thenReturn(""" map: ut4_casa num score ping name lastmsg address qport rate --- ----- ---- --------------- ------- --------------------- ----- ----- 12 0 10 superman 0 192.168.1.12:53039 9993 15000 """) self.console.authorizeClients() verify(self.output_mock).write('status', maxRetries=anything()) verify(superman).auth()
def setUp(self): super(Test_client_connects, self).setUp() self.conf = CfgConfigParser() self.conf.loadFromString("""[foo]""") self.p = VacbanPlugin(self.console, self.conf) self.p.onLoadConfig() when(self.p)._checkConnectedPlayers().thenReturn() self.p.onStartup() when(self.p)._query_service(anything()).thenReturn(vac_response_not_banned)
def test__checkClient__not_found(self): # GIVEN when(self.p)._query_service(anything()).thenReturn(vac_response_not_found) self.joe.connects("slot1") # WHEN with patch.object(self.p, "_takeActionAgainst") as mock_takeActionAgainst: self.p._checkClient(self.joe) # THEN self.assertEqual(0, mock_takeActionAgainst.call_count)
def test_unexpected_exception(self): # GIVEN when(self.console.storage).getClient(anything()).thenRaise(NotImplementedError()) joe = FakeClient(console=self.console, name="Joe", guid="joe_guid") # WHEN with patch.object(self.console, "error") as error_mock: joe.auth() # THEN error_mock.assert_called_with('Auth self.console.storage.getClient(client) - Client<@0:joe_guid|:"Joe":None>', exc_info=ANY)
def setUp(self): super(Test_client_connects, self).setUp() self.conf = CfgConfigParser() self.conf.loadFromString("""[foo]""") self.p = VacbanPlugin(self.console, self.conf) self.p.onLoadConfig() when(self.p)._checkConnectedPlayers().thenReturn() self.p.onStartup() when(self.p)._query_service( anything()).thenReturn(vac_response_not_banned)
def test__checkClient__error(self): # GIVEN when(self.p)._query_service(anything()).thenRaise( NotImplementedError('foo')) self.joe.connects("slot1") # WHEN with patch.object(self.p, "_takeActionAgainst") as mock_takeActionAgainst: self.p._checkClient(self.joe) # THEN self.assertEqual(0, mock_takeActionAgainst.call_count)
def test__checkClient__not_found(self): # GIVEN when(self.p)._query_service( anything()).thenReturn(vac_response_not_found) self.joe.connects("slot1") # WHEN with patch.object(self.p, "_takeActionAgainst") as mock_takeActionAgainst: self.p._checkClient(self.joe) # THEN self.assertEqual(0, mock_takeActionAgainst.call_count)
def test_sync(self): """ For all connected players returned by self.getPlayerList(), get the matching Client object from self.clients (with self.clients.getByCID(cid) or similar methods) and look for inconsistencies. If required call the client.disconnect() method to remove a client from self.clients. This is mainly useful for games where clients are identified by the slot number they occupy. On map change, a player A on slot 1 can leave making room for player B who connects on slot 1. """ self.console.sync() verify(self.output_mock).write('status', maxRetries=anything())
def setUp(self): super(Test_commands, self).setUp() self.conf = CfgConfigParser() self.conf.loadFromString("""[commands] vaccheck: 20 """) self.p = VacbanPlugin(self.console, self.conf) self.p.onLoadConfig() self.p.onStartup() when(self.p)._query_service(anything()).thenReturn(vac_response_not_banned) self.moderator.connects("2")
def test_getPlayerList_without_punkbuster(self): # GIVEN self.console.PunkBuster = None when(self.console).write('status', maxRetries=anything()).thenReturn(""" map: mp_backlot num score ping guid name lastmsg address qport rate --- ----- ---- -------------------------------- --------------- ------- --------------------- ----- ----- 0 0 3 GameRanger-Account-ID_0006400896 Ranger^7 50 103.231.162.141:16000 7068 25000 """) # WHEN rv = self.console.getPlayerList() # THEN self.assertDictEqual({'slot': '0', 'score': '0', 'ping': '3', 'guid': '0006400896', 'name': 'Ranger^7', 'last': '50', 'ip': '103.231.162.141', 'port': '16000', 'qport': '7068', 'rate': '25000', 'pbid': None}, rv.get("0", {}), rv)
def setUp(self): super(Test_commands, self).setUp() self.conf = CfgConfigParser() self.conf.loadFromString("""[commands] vaccheck: 20 """) self.p = VacbanPlugin(self.console, self.conf) self.p.onLoadConfig() self.p.onStartup() when(self.p)._query_service( anything()).thenReturn(vac_response_not_banned) self.moderator.connects("2")
def test_queryAllFrozenSandAccount(self): # GIVEN when(self.console).write('auth-whois all', maxRetries=anything()).thenReturn(r'''No player found for "all". auth: id: 0 - name: ^7laCourge - login: courgette - notoriety: serious - level: -1 auth: id: 1 - name: ^7f00 - login: - notoriety: 0 - level: 0 - ^7no account auth: id: 2 - name: ^7Qant - login: qant - notoriety: basic - level: -1 ''') # WHEN data = self.console.queryAllFrozenSandAccount() # THEN self.assertDictEqual({'0': {'cid': '0', 'extra': None, 'level': '-1', 'login': '******', 'name': 'laCourge', 'notoriety': 'serious'}, '1': {'cid': '1', 'extra': "^7no account", 'level': '0', 'login': '', 'name': 'f00', 'notoriety': '0'}, '2': {'cid': '2', 'extra': None, 'level': '-1', 'login': '******', 'name': 'Qant', 'notoriety': 'basic'} }, data)
def test_getPlayerList(self): # GIVEN when(self.console).write('status', maxRetries=anything()).thenReturn('''\ map: ut4_casa num score ping name lastmsg address qport rate --- ----- ---- --------------- ------- --------------------- ----- ----- 4 0 141 theName^7 0 11.22.33.44:27961 38410 8000 5 0 48 theName2^7 0 11.22.33.45:27961 38410 8000 ''') # WHEN rv = self.console.getPlayerList() # THEN self.assertDictContainsSubset({ '5': {'slot': '5', 'last': '0', 'name': 'theName2^7', 'ip': '11.22.33.45', 'ping': '48', 'pbid': None, 'qport': '38410', 'rate': '8000', 'score': '0', 'port': '27961'}, '4': {'slot': '4', 'last': '0', 'name': 'theName^7', 'ip': '11.22.33.44', 'ping': '141', 'pbid': None, 'qport': '38410', 'rate': '8000', 'score': '0', 'port': '27961'} }, rv)
def test_getPlayerList_without_punkbuster(self): # GIVEN self.console.PunkBuster = None when(self.console).write('status', maxRetries=anything()).thenReturn('''\ map: mp_stadium num score ping guid name lastmsg address qport rate --- ----- ---- ---------- --------------- ------- --------------------- ------ ----- 0 0 0 0 democlient^7 362150 unknown 1773 5000 1 200 47 8326146 ShaGGyTuBBs^7 0 11.11.11.11:524 16783 25000 2 1360 61 56089378 fresh breeze^7 0 11.11.11.11:-27409 -7422 25000 3 470 97 69406003 kossi__86^7 0 11.11.11.11:524 -24017 25000 ''') # WHEN rv = self.console.getPlayerList() # THEN self.assertNotIn("0", rv) self.assertDictContainsSubset({'slot': '1', 'score': '200', 'ping': '47', 'guid': '8326146', 'name': 'ShaGGyTuBBs^7', 'last': '0', 'ip': '11.11.11.11', 'port': '524', 'qport': '16783', 'rate': '25000', 'pbid': None}, rv.get("1", {})) self.assertDictContainsSubset({'slot': '2', 'score': '1360', 'ping': '61', 'guid': '56089378', 'name': 'fresh breeze^7', 'last': '0', 'ip': '11.11.11.11', 'port': '-27409', 'qport': '7422', 'rate': '25000', 'pbid': None}, rv.get("2", {})) self.assertDictContainsSubset({'slot': '3', 'score': '470', 'ping': '97', 'guid': '69406003', 'name': 'kossi__86^7', 'last': '0', 'ip': '11.11.11.11', 'port': '524', 'qport': '24017', 'rate': '25000', 'pbid': None}, rv.get("3", {}))
def test_changeMap(self, sleep_mock): """ load a given map/level return a list of suggested map names in cases it fails to recognize the map that was provided """ when(self.output_mock).write('fdir *.bsp', socketTimeout=anything()).thenReturn("""\ --------------- maps/ut4_abbey.bsp maps/ut4_abbeyctf.bsp maps/ut4_algiers.bsp maps/ut4_austria.bsp maps/ut4_casa.bsp """) suggestions = self.console.changeMap('algier') self.assertIsNone(suggestions) verify(self.output_mock).write('map ut4_algiers') suggestions = self.console.changeMap('bey') self.assertIsNotNone(suggestions) self.assertSetEqual({'ut4_abbey', 'ut4_abbeyctf'}, set(suggestions))
def test_getPlayerList(self): # GIVEN when(self.console).write('status', maxRetries=anything()).thenReturn('''\ map: ut4_casa num score ping name lastmsg address qport rate --- ----- ---- --------------- ------- --------------------- ----- ----- 4 0 141 theName^7 0 11.22.33.44:27961 38410 8000 5 0 48 theName2^7 0 11.22.33.45:27961 38410 8000 ''') # WHEN rv = self.console.getPlayerList() # THEN self.assertDictContainsSubset( { '5': { 'slot': '5', 'last': '0', 'name': 'theName2^7', 'ip': '11.22.33.45', 'ping': '48', 'pbid': None, 'qport': '38410', 'rate': '8000', 'score': '0', 'port': '27961' }, '4': { 'slot': '4', 'last': '0', 'name': 'theName^7', 'ip': '11.22.33.44', 'ping': '141', 'pbid': None, 'qport': '38410', 'rate': '8000', 'score': '0', 'port': '27961' } }, rv)
def test_queryAllFrozenSandAccount(self): # GIVEN when(self.console).write( 'auth-whois all', maxRetries=anything()).thenReturn(r'''No player found for "all". auth: id: 0 - name: ^7laCourge - login: courgette - notoriety: serious - level: -1 auth: id: 1 - name: ^7f00 - login: - notoriety: 0 - level: 0 - ^7no account auth: id: 2 - name: ^7Qant - login: qant - notoriety: basic - level: -1 ''') # WHEN data = self.console.queryAllFrozenSandAccount() # THEN self.assertDictEqual( { '0': { 'cid': '0', 'extra': None, 'level': '-1', 'login': '******', 'name': 'laCourge', 'notoriety': 'serious' }, '1': { 'cid': '1', 'extra': "^7no account", 'level': '0', 'login': '', 'name': 'f00', 'notoriety': '0' }, '2': { 'cid': '2', 'extra': None, 'level': '-1', 'login': '******', 'name': 'Qant', 'notoriety': 'basic' } }, data)
def test_getPlayerList_without_punkbuster(self): # GIVEN self.console.PunkBuster = None when(self.console).write('status', maxRetries=anything()).thenReturn('''\ map: mp_gits_tanks num score ping guid name lastmsg address qport rate --- ----- ---- ---------- --------------- ------- --------------------- ------ ----- 0 0 349 784729936 BagpipeHero^7 50 11.11.11.11:28960 7309 25000 1 0 999 680213351 US_Wannabe^7 750 11.11.11.11:28960 -13830 25000 2 1230 159 1689890858 2cool4yaD^7 0 11.11.11.11:-9427 31128 25000 3 1520 163 763506664 SestaPT^7 0 11.11.11.11:28960 -9436 25000 4 410 129 281198399 xRedoxX^7 0 11.11.11.11:29195 -28834 25000 5 0 999 1359560555 MikeIsDaBomb^7 0 11.11.11.11:28960 -20411 25000 ''') # WHEN rv = self.console.getPlayerList() # THEN self.assertDictEqual({'slot': '0', 'score': '0', 'ping': '349', 'guid': '784729936', 'name': 'BagpipeHero^7', 'last': '50', 'ip': '11.11.11.11', 'port': '28960', 'qport': '7309', 'rate': '25000', 'pbid': None}, rv.get("0", {})) self.assertDictEqual({'slot': '1', 'score': '0', 'ping': '999', 'guid': '680213351', 'name': 'US_Wannabe^7', 'last': '750', 'ip': '11.11.11.11', 'port': '28960', 'qport': '-13830', 'rate': '25000', 'pbid': None}, rv.get("1", {})) self.assertDictEqual({'slot': '2', 'score': '1230', 'ping': '159', 'guid': '1689890858', 'name': '2cool4yaD^7', 'last': '0', 'ip': '11.11.11.11', 'port': '-9427', 'qport': '31128', 'rate': '25000', 'pbid': None}, rv.get("2", {})) self.assertDictEqual({'slot': '3', 'score': '1520', 'ping': '163', 'guid': '763506664', 'name': 'SestaPT^7', 'last': '0', 'ip': '11.11.11.11', 'port': '28960', 'qport': '-9436', 'rate': '25000', 'pbid': None}, rv.get("3", {})) self.assertDictEqual({'slot': '4', 'score': '410', 'ping': '129', 'guid': '281198399', 'name': 'xRedoxX^7', 'last': '0', 'ip': '11.11.11.11', 'port': '29195', 'qport': '-28834', 'rate': '25000', 'pbid': None}, rv.get("4", {})) self.assertDictEqual({'slot': '5', 'score': '0', 'ping': '999', 'guid': '1359560555', 'name': 'MikeIsDaBomb^7', 'last': '0', 'ip': '11.11.11.11', 'port': '28960', 'qport': '-20411', 'rate': '25000', 'pbid': None}, rv.get("5", {}))
def test_getPlayerList_without_punkbuster(self): # GIVEN self.console.PunkBuster = None when(self.console).write('status', maxRetries=anything()).thenReturn('''\ map: mp_villa num score ping guid name lastmsg address qport rate --- ----- ---- ---------- --------------- ------- --------------------- ------ ----- 0 0 0 0 democlient^7 1650 unknown 1773 5000 1 0 55 63281996 BandAid^7 50 11.11.11.11:524 8045 25000 2 0 157 81554346 hugobongenhielm^7 50 11.11.11.11:524 22481 25000 3 0 156 86330555 Irish^7 0 11.11.11.11:9162 14288 25000 4 0 999 68003079 Ashhole^7 750 11.11.11.11:19978 19033 25000 5 5 53 318670 bigredtwit^7 011.11.11.11:28966 1259 25000 ''') # WHEN rv = self.console.getPlayerList() # THEN self.assertDictContainsSubset( { 'slot': '1', 'score': '0', 'ping': '55', 'guid': '63281996', 'name': 'BandAid^7', 'last': '50', 'ip': '11.11.11.11', 'pbid': None }, rv.get('1', {}), rv) self.assertDictContainsSubset( { 'slot': '2', 'score': '0', 'ping': '157', 'guid': '81554346', 'name': 'hugobongenhielm^7', 'last': '50', 'ip': '11.11.11.11', 'pbid': None }, rv.get('2', {}), rv) self.assertDictContainsSubset( { 'slot': '3', 'score': '0', 'ping': '156', 'guid': '86330555', 'name': 'Irish^7', 'last': '0', 'ip': '11.11.11.11', 'pbid': None }, rv.get('3', {}), rv) self.assertDictContainsSubset( { 'slot': '4', 'score': '0', 'ping': '999', 'guid': '68003079', 'name': 'Ashhole^7', 'last': '750', 'ip': '11.11.11.11', 'pbid': None }, rv.get('4', {}), rv) self.assertDictContainsSubset( { 'slot': '5', 'score': '5', 'ping': '53', 'guid': '318670', 'name': 'bigredtwit^7', 'last': '0', 'ip': '11.11.11.11', 'pbid': None }, rv.get('5', {}), rv)
def test_changeMap_2(self, sleep_mock): """ see http://forum.bigbrotherbot.net/urt/!map-x-bug/msg37759/#msg37759 """ when(self.output_mock).write('fdir *.bsp', socketTimeout=anything()).thenReturn("""\ --------------- maps/ut4_abbey.bsp maps/ut4_abbeyctf.bsp maps/ut4_algiers.bsp maps/ut4_ambush.bsp maps/ut4_area3_b4.bsp maps/ut4_asylum_b1.bsp maps/ut4_austria.bsp maps/ut4_aztek_b2.bsp maps/ut4_baeza.bsp maps/ut4_beijing_b3.bsp maps/ut4_blackhawk.bsp maps/ut4_blitzkrieg.bsp maps/ut4_boxtrot_x6.bsp maps/ut4_cambridge_b1.bsp maps/ut4_cambridge_fixed.bsp maps/ut4_casa.bsp maps/ut4_commune.bsp maps/ut4_company.bsp maps/ut4_crossing.bsp maps/ut4_deception_v2.bsp maps/ut4_desolate_rc1.bsp maps/ut4_docks.bsp maps/ut4_dressingroom.bsp maps/ut4_druglord2.bsp maps/ut4_dust2_v2.bsp maps/ut4_dust2_v3b.bsp maps/ut4_eagle.bsp maps/ut4_eezabad.bsp maps/ut4_elgin.bsp maps/ut4_exhibition_a24.bsp maps/ut4_facade_b5.bsp maps/ut4_ferguson_b12.bsp maps/ut4_firingrange.bsp maps/ut4_granja.bsp maps/ut4_guerrilla.bsp maps/ut4_harbortown.bsp maps/ut4_heroic_beta1.bsp maps/ut4_herring.bsp maps/ut4_horror.bsp maps/ut4_kingdom.bsp maps/ut4_kingdom_rc6.bsp maps/ut4_kingpin.bsp maps/ut4_mandolin.bsp maps/ut4_maximus_v1.bsp maps/ut4_maya.bsp maps/ut4_metropolis_b2.bsp maps/ut4_oildepot.bsp maps/ut4_orbital_sl.bsp maps/ut4_pandora_b7.bsp maps/ut4_paradise.bsp maps/ut4_paris_v2.bsp maps/ut4_poland_b11.bsp maps/ut4_prague.bsp maps/ut4_ramelle.bsp maps/ut4_ricochet.bsp maps/ut4_riyadh.bsp maps/ut4_roma_beta2b.bsp maps/ut4_sanc.bsp maps/ut4_shahideen.bsp maps/ut4_snoppis.bsp maps/ut4_subterra.bsp maps/ut4_suburbs.bsp maps/ut4_subway.bsp maps/ut4_swim.bsp maps/ut4_terrorism7.bsp maps/ut4_thingley.bsp maps/ut4_tohunga_b8.bsp maps/ut4_tombs.bsp maps/ut4_toxic.bsp maps/ut4_train_dl1.bsp maps/ut4_tunis.bsp maps/ut4_turnpike.bsp maps/ut4_uptown.bsp maps/ut4_venice_b7.bsp maps/ut4_village.bsp 75 files listed """) suggestions = self.console.changeMap('tohunga') self.assertIsNone(suggestions) verify(self.output_mock).write('map ut4_tohunga_b8')
def test_getPlayerList_without_punkbuster(self): # GIVEN self.console.PunkBuster = None when(self.console).write('status', maxRetries=anything()).thenReturn('''\ map: mp_gits_tanks num score ping guid name lastmsg address qport rate --- ----- ---- ---------- --------------- ------- --------------------- ------ ----- 0 0 349 784729936 BagpipeHero^7 50 11.11.11.11:28960 7309 25000 1 0 999 680213351 US_Wannabe^7 750 11.11.11.11:28960 -13830 25000 2 1230 159 1689890858 2cool4yaD^7 0 11.11.11.11:-9427 31128 25000 3 1520 163 763506664 SestaPT^7 0 11.11.11.11:28960 -9436 25000 4 410 129 281198399 xRedoxX^7 0 11.11.11.11:29195 -28834 25000 5 0 999 1359560555 MikeIsDaBomb^7 0 11.11.11.11:28960 -20411 25000 ''') # WHEN rv = self.console.getPlayerList() # THEN self.assertDictEqual( { 'slot': '0', 'score': '0', 'ping': '349', 'guid': '784729936', 'name': 'BagpipeHero^7', 'last': '50', 'ip': '11.11.11.11', 'port': '28960', 'qport': '7309', 'rate': '25000', 'pbid': None }, rv.get("0", {})) self.assertDictEqual( { 'slot': '1', 'score': '0', 'ping': '999', 'guid': '680213351', 'name': 'US_Wannabe^7', 'last': '750', 'ip': '11.11.11.11', 'port': '28960', 'qport': '-13830', 'rate': '25000', 'pbid': None }, rv.get("1", {})) self.assertDictEqual( { 'slot': '2', 'score': '1230', 'ping': '159', 'guid': '1689890858', 'name': '2cool4yaD^7', 'last': '0', 'ip': '11.11.11.11', 'port': '-9427', 'qport': '31128', 'rate': '25000', 'pbid': None }, rv.get("2", {})) self.assertDictEqual( { 'slot': '3', 'score': '1520', 'ping': '163', 'guid': '763506664', 'name': 'SestaPT^7', 'last': '0', 'ip': '11.11.11.11', 'port': '28960', 'qport': '-9436', 'rate': '25000', 'pbid': None }, rv.get("3", {})) self.assertDictEqual( { 'slot': '4', 'score': '410', 'ping': '129', 'guid': '281198399', 'name': 'xRedoxX^7', 'last': '0', 'ip': '11.11.11.11', 'port': '29195', 'qport': '-28834', 'rate': '25000', 'pbid': None }, rv.get("4", {})) self.assertDictEqual( { 'slot': '5', 'score': '0', 'ping': '999', 'guid': '1359560555', 'name': 'MikeIsDaBomb^7', 'last': '0', 'ip': '11.11.11.11', 'port': '28960', 'qport': '-20411', 'rate': '25000', 'pbid': None }, rv.get("5", {}))
def test_getPlayerList_without_punkbuster(self): # GIVEN self.console.PunkBuster = None when(self.console).write("status", maxRetries=anything()).thenReturn( """\ map: mp_stadium num score ping guid name lastmsg address qport rate --- ----- ---- ---------- --------------- ------- --------------------- ------ ----- 0 0 0 0 democlient^7 362150 unknown 1773 5000 1 200 47 8326146 ShaGGyTuBBs^7 0 11.11.11.11:524 16783 25000 2 1360 61 56089378 fresh breeze^7 0 11.11.11.11:-27409 -7422 25000 3 470 97 69406003 kossi__86^7 0 11.11.11.11:524 -24017 25000 """ ) # WHEN rv = self.console.getPlayerList() # THEN self.assertNotIn("0", rv) self.assertDictContainsSubset( { "slot": "1", "score": "200", "ping": "47", "guid": "8326146", "name": "ShaGGyTuBBs^7", "last": "0", "ip": "11.11.11.11", "port": "524", "qport": "16783", "rate": "25000", "pbid": None, }, rv.get("1", {}), ) self.assertDictContainsSubset( { "slot": "2", "score": "1360", "ping": "61", "guid": "56089378", "name": "fresh breeze^7", "last": "0", "ip": "11.11.11.11", "port": "-27409", "qport": "7422", "rate": "25000", "pbid": None, }, rv.get("2", {}), ) self.assertDictContainsSubset( { "slot": "3", "score": "470", "ping": "97", "guid": "69406003", "name": "kossi__86^7", "last": "0", "ip": "11.11.11.11", "port": "524", "qport": "24017", "rate": "25000", "pbid": None, }, rv.get("3", {}), )