Example #1
0
 def _assert(self, conf_data=None, expected=None):
     self.parser.config = XmlConfigParser()
     self.parser.config.loadFromString("""
         <configuration>
             <settings name="bf3">%s</settings>
         </configuration>
         """ % (('<set name="max_say_line_length">%s</set>' % conf_data) if conf_data is not None else ''))
     Bf3Parser.load_conf_max_say_line_length(self.parser)
     if expected:
         self.assertEqual(expected, self.parser._settings['line_length'])
Example #2
0
 def _test_message_delay(self, conf_data=None, expected=None):
     self.parser.config = XmlConfigParser()
     self.parser.config.loadFromString("""
         <configuration>
             <settings name="bf3">%s</settings>
         </configuration>
         """ % (('<set name="message_delay">%s</set>' % conf_data) if conf_data is not None else ''))
     Bf3Parser.load_config_message_delay(self.parser)
     if expected:
         self.assertEqual(expected, self.parser._settings['message_delay'])
Example #3
0
 def _test_message_delay(self, conf_data=None, expected=None):
     self.parser.config = XmlConfigParser()
     self.parser.config.loadFromString("""
         <configuration>
             <settings name="bf3">%s</settings>
         </configuration>
         """ % (('<set name="message_delay">%s</set>' %
                 conf_data) if conf_data is not None else ''))
     Bf3Parser.load_config_message_delay(self.parser)
     if expected:
         self.assertEqual(expected, self.parser._settings['message_delay'])
Example #4
0
 def _assert(self, conf_data=None, expected=None):
     self.parser.config = XmlConfigParser()
     self.parser.config.loadFromString("""
         <configuration>
             <settings name="bf3">%s</settings>
         </configuration>
         """ % (('<set name="max_say_line_length">%s</set>' %
                 conf_data) if conf_data is not None else ''))
     Bf3Parser.load_conf_max_say_line_length(self.parser)
     if expected:
         self.assertEqual(expected, self.parser._settings['line_length'])
Example #5
0
 def setUp(self):
     self.conf = XmlConfigParser()
     self.conf.loadFromString("""
             <configuration>
             </configuration>
         """)
     self.parser = Bf3Parser(self.conf)
     self.parser.startup()
Example #6
0
 def setUp(self):
     BF3TestCase.setUp(self)
     self.conf = XmlConfigParser()
     self.conf.loadFromString("""
             <configuration>
             </configuration>
         """)
     self.parser = Bf3Parser(self.conf)
Example #7
0
 def setUp(self):
     BF3TestCase.setUp(self)
     self.conf = XmlConfigParser()
     self.conf.loadFromString("""
             <configuration>
             </configuration>
         """)
     self.parser = Bf3Parser(self.conf)
     self.foobar = self.parser.clients.newClient(cid='Foobar', name='Foobar', guid="FoobarGuid")
Example #8
0
 def setUp(self):
     BF3TestCase.setUp(self)
     self.conf = XmlConfigParser()
     self.conf.loadFromString("""
             <configuration>
             </configuration>
         """)
     self.parser = Bf3Parser(self.conf)
     self.p1 = FakeClient(self.parser, name="Player1")
     self.p2 = FakeClient(self.parser, name="Player2")
Example #9
0
 def setUp(self):
     self.conf = XmlConfigParser()
     self.conf.loadFromString("""
             <configuration>
             </configuration>
         """)
     self.parser = Bf3Parser(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)
Example #10
0
    def setUp(self):
        BF3TestCase.setUp(self)
        self.conf = XmlConfigParser()
        self.conf.loadFromString("<configuration/>")
        self.parser = Bf3Parser(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]
Example #11
0
    def test_getServerInfo_R9(self):

        bf3_response = [
            'i3D.net - BigBrotherBot #3 (FR)', '0', '16', 'SquadDeathMatch0',
            'MP_013', '0', '1', '4', '0', '0', '0', '0', '50', '', 'true',
            'true', 'false', '92480', '4832', '4.5.6.7:542', '', '', 'EU',
            'ams', 'DE'
        ]
        parser = Mock(spec=Bf3Parser)
        parser.write = lambda x: bf3_response

        data = Bf3Parser.getServerInfo(parser)
        self.assertEqual(bf3_response, data)
        self.assertEqual(parser.game.sv_hostname,
                         'i3D.net - BigBrotherBot #3 (FR)')
        self.assertEqual(parser.game.sv_maxclients, 16)
        self.assertEqual(parser.game.gameType, 'SquadDeathMatch0')
        self.assertEqual(parser._publicIp, '4.5.6.7')
        self.assertEqual(parser._gamePort, '542')
        self.assertEqual(
            {
                'serverName': 'i3D.net - BigBrotherBot #3 (FR)',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'SquadDeathMatch0',
                'level': 'MP_013',
                'roundsPlayed': '0',
                'roundsTotal': '1',
                'numTeams': '4',
                'team1score': '0',
                'team2score': '0',
                'team3score': '0',
                'team4score': '0',
                'targetScore': '50',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '92480',
                'roundTime': '4832',
                'gameIpAndPort': '4.5.6.7:542',
                'punkBusterVersion': '',
                'joinQueueEnabled': '',
                'region': 'EU',
                'closestPingSite': 'ams',
                'country': 'DE',
            }, parser.game.serverinfo)
Example #12
0
    def test_getServerInfo_pre_R9(self):
        self.maxDiff = None
        bf3_response = ('BigBrotherBot #2', '0', '16', 'ConquestLarge0',
                        'MP_012', '1', '2', '4', '300', '215', '25', '84', '0',
                        '', 'true', 'true', 'false', '5148', '455')
        parser = Mock(spec=Bf3Parser)
        parser.write = lambda x: bf3_response

        data = Bf3Parser.getServerInfo(parser)
        self.assertEqual(bf3_response, data)
        self.assertEqual(parser.game.sv_hostname, 'BigBrotherBot #2')
        self.assertEqual(parser.game.sv_maxclients, 16)
        self.assertEqual(parser.game.gameType, 'ConquestLarge0')
        self.assertFalse(parser._publicIp.called)
        self.assertFalse(parser._port.called)

        self.assertEqual(
            {
                'serverName': 'BigBrotherBot #2',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'ConquestLarge0',
                'level': 'MP_012',
                'roundsPlayed': '1',
                'roundsTotal': '2',
                'numTeams': '4',
                'team1score': '300',
                'team2score': '215',
                'team3score': '25',
                'team4score': '84',
                'targetScore': '0',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '5148',
                'roundTime': '455',
                'gameIpAndPort': None,
                'punkBusterVersion': None,
                'joinQueueEnabled': None,
                'region': None,
                'closestPingSite': None,
                'country': None,
            }, parser.game.serverinfo)
Example #13
0
    def test_getServerInfo_pre_R9(self):
        self.maxDiff = None
        bf3_response = ('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012', '1', '2',
                                  '4', '300', '215', '25', '84',
                                  '0', '', 'true', 'true', 'false', '5148', '455')
        parser = Mock(spec=Bf3Parser)
        parser.write = lambda x: bf3_response

        data = Bf3Parser.getServerInfo(parser)
        self.assertEqual(bf3_response, data)
        self.assertEqual(parser.game.sv_hostname, 'BigBrotherBot #2')
        self.assertEqual(parser.game.sv_maxclients, 16)
        self.assertEqual(parser.game.gameType, 'ConquestLarge0')
        self.assertFalse(parser._publicIp.called)
        self.assertFalse(parser._port.called)

        self.assertEqual({
            'serverName': 'BigBrotherBot #2',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'ConquestLarge0',
            'level': 'MP_012',
            'roundsPlayed': '1',
            'roundsTotal': '2',
            'numTeams': '4',
            'team1score': '300',
            'team2score': '215',
            'team3score': '25',
            'team4score': '84',
            'targetScore': '0',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '5148',
            'roundTime': '455',
            'gameIpAndPort': None,
            'punkBusterVersion': None,
            'joinQueueEnabled': None,
            'region': None,
            'closestPingSite': None,
            'country': None,
        }, parser.game.serverinfo)
Example #14
0
    def test_getServerInfo_R9(self):

        bf3_response = ['i3D.net - BigBrotherBot #3 (FR)', '0', '16', 'SquadDeathMatch0', 'MP_013',
                        '0', '1','4', '0', '0', '0', '0', '50', '', 'true', 'true', 'false', '92480',
                        '4832', '4.5.6.7:542', '', '', 'EU', 'ams', 'DE']
        parser = Mock(spec=Bf3Parser)
        parser.write = lambda x: bf3_response

        data = Bf3Parser.getServerInfo(parser)
        self.assertEqual(bf3_response, data)
        self.assertEqual(parser.game.sv_hostname, 'i3D.net - BigBrotherBot #3 (FR)')
        self.assertEqual(parser.game.sv_maxclients, 16)
        self.assertEqual(parser.game.gameType, 'SquadDeathMatch0')
        self.assertEqual(parser._publicIp, '4.5.6.7')
        self.assertEqual(parser._gamePort, '542')
        self.assertEqual({
            'serverName': 'i3D.net - BigBrotherBot #3 (FR)',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'SquadDeathMatch0',
            'level': 'MP_013',
            'roundsPlayed': '0',
            'roundsTotal': '1',
            'numTeams': '4',
            'team1score': '0',
            'team2score': '0',
            'team3score': '0',
            'team4score': '0',
            'targetScore': '50',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '92480',
            'roundTime': '4832',
            'gameIpAndPort': '4.5.6.7:542',
            'punkBusterVersion': '',
            'joinQueueEnabled': '',
            'region': 'EU',
            'closestPingSite': 'ams',
            'country': 'DE',
        }, parser.game.serverinfo)
Example #15
0
    def setUp(self):
        BF3TestCase.setUp(self)
        with logging_disabled():
            self.conf = XmlConfigParser()
            self.conf.loadFromString("""
                    <configuration>
                    </configuration>
                """)
            self.parser = Bf3Parser(self.conf)
            adminPlugin_conf = CfgConfigParser()
            adminPlugin_conf.loadFromString(r"""
[commands]
map: 20
""")
            adminPlugin = AdminPlugin(self.parser, adminPlugin_conf)
            adminPlugin.onLoadConfig()
            adminPlugin.onStartup()
            when(self.parser).getPlugin('admin').thenReturn(adminPlugin)
            self.parser.patch_b3_admin_plugin()
            self.joe = FakeClient(self.parser, name="Joe", guid="joeguid", groupBits=128)
            self.joe.connects(cid="joe")
            self.parser.game.gameType = "CaptureTheFlag0"
            self.parser.game.serverinfo = {'roundsTotal': 2}
Example #16
0
    def test_decodeServerinfo_R9(self):
        self.maxDiff = None
        self.assertDictEqual({
            'serverName': 'BigBrotherBot #2',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'ConquestLarge0',
            'level': 'MP_012',
            'roundsPlayed': '0',
            'roundsTotal': '2',
            'numTeams': '0',
            'team1score': None,
            'team2score': None,
            'team3score': None,
            'team4score': None,
            'targetScore': '0',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '5148',
            'roundTime': '455',
            'gameIpAndPort': '1.2.3.4:5445',
            'punkBusterVersion': '1.5',
            'joinQueueEnabled': 'false',
            'region': 'EU',
            'closestPingSite': '45',
            'country': 'FR',
        }, Bf3Parser.decodeServerinfo(('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012', '0', '2', '0', '0', '', 'true', 'true', 'false', '5148', '455', '1.2.3.4:5445', '1.5', 'false', 'EU', '45', 'FR')))

        self.assertDictEqual({
            'serverName': 'BigBrotherBot #2',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'ConquestLarge0',
            'level': 'MP_012',
            'roundsPlayed': '0',
            'roundsTotal': '2',
            'numTeams': '1',
            'team1score': '47',
            'team2score': None,
            'team3score': None,
            'team4score': None,
            'targetScore': '0',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '5148',
            'roundTime': '455',
            'gameIpAndPort': '1.2.3.4:5445',
            'punkBusterVersion': '1.5',
            'joinQueueEnabled': 'false',
            'region': 'EU',
            'closestPingSite': '45',
            'country': 'FR',
        }, Bf3Parser.decodeServerinfo(('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012', '0', '2', '1', '47', '0', '', 'true', 'true', 'false', '5148', '455', '1.2.3.4:5445', '1.5', 'false', 'EU', '45', 'FR')))

        self.assertDictEqual({
            'serverName': 'BigBrotherBot #2',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'ConquestLarge0',
            'level': 'MP_012',
            'roundsPlayed': '0',
            'roundsTotal': '2',
            'numTeams': '2',
            'team1score': '300',
            'team2score': '300',
            'team3score': None,
            'team4score': None,
            'targetScore': '0',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '5148',
            'roundTime': '455',
            'gameIpAndPort': '1.2.3.4:5445',
            'punkBusterVersion': '1.5',
            'joinQueueEnabled': 'false',
            'region': 'EU',
            'closestPingSite': '45',
            'country': 'FR',
        }, Bf3Parser.decodeServerinfo(('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012', '0', '2', '2', '300', '300', '0', '', 'true', 'true', 'false', '5148', '455', '1.2.3.4:5445', '1.5', 'false', 'EU', '45', 'FR')))

        self.assertDictEqual({
            'serverName': 'BigBrotherBot #2',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'ConquestLarge0',
            'level': 'MP_012',
            'roundsPlayed': '1',
            'roundsTotal': '2',
            'numTeams': '3',
            'team1score': '300',
            'team2score': '215',
            'team3score': '25',
            'team4score': None,
            'targetScore': '0',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '5148',
            'roundTime': '455',
            'gameIpAndPort': '1.2.3.4:5445',
            'punkBusterVersion': '1.5',
            'joinQueueEnabled': 'false',
            'region': 'EU',
            'closestPingSite': '45',
            'country': 'FR',
        }, Bf3Parser.decodeServerinfo(('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012', '1', '2', '3', '300', '215', '25', '0', '', 'true', 'true', 'false', '5148', '455', '1.2.3.4:5445', '1.5', 'false', 'EU', '45', 'FR')))

        self.assertDictEqual({
            'serverName': 'BigBrotherBot #2',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'ConquestLarge0',
            'level': 'MP_012',
            'roundsPlayed': '1',
            'roundsTotal': '2',
            'numTeams': '4',
            'team1score': '300',
            'team2score': '215',
            'team3score': '25',
            'team4score': '84',
            'targetScore': '0',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '5148',
            'roundTime': '455',
            'gameIpAndPort': '1.2.3.4:5445',
            'punkBusterVersion': '1.5',
            'joinQueueEnabled': 'false',
            'region': 'EU',
            'closestPingSite': '45',
            'country': 'FR',
        }, Bf3Parser.decodeServerinfo(('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012', '1', '2', '4', '300', '215', '25', '84', '0', '', 'true', 'true', 'false', '5148', '455', '1.2.3.4:5445', '1.5', 'false', 'EU', '45', 'FR')))
Example #17
0
    def setUp(self):
        # create a BF3 parser
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString("""<configuration />""")
        self.console = Bf3Parser(self.parser_conf)

        # alter a few settings to speed up the tests
        self.console.sayqueue_get_timeout = 0
        self.console._settings['message_delay'] = 0

        self.console.startup()

        # simulate game server actions
        def frostbitewrite(msg, maxRetries=1, needConfirmation=False):
            print "   >>> %s" % repr(msg)
            if msg[0] == 'admin.movePlayer':
                self.console.routeFrostbitePacket(['player.onTeamChange'] +
                                                  list(msg[1:]))
            else:
                return mock.DEFAULT  # will make Mockito fall back on return_value and wrapped function

        self.console.write = Mockito(wraps=self.console.write,
                                     side_effect=frostbitewrite)

        # load the admin plugin
        self.adminPlugin = AdminPlugin(self.console,
                                       '@b3/conf/plugin_admin.xml')
        self.adminPlugin.onStartup()

        # make sure the admin plugin obtained by other plugins is our admin plugin
        def getPlugin(name):
            if name == 'admin':
                return self.adminPlugin
            else:
                return self.console.getPlugin(name)

        self.console.getPlugin = getPlugin

        self.console.patch_b3_admin_plugin()

        # prepare a few players
        self.joe = FakeClient(self.console,
                              name="Joe",
                              exactName="Joe",
                              guid="zaerezarezar",
                              groupBits=1,
                              team=TEAM_UNKNOWN,
                              teamId=0,
                              squad=0)
        self.simon = FakeClient(self.console,
                                name="Simon",
                                exactName="Simon",
                                guid="qsdfdsqfdsqf",
                                groupBits=0,
                                team=TEAM_UNKNOWN,
                                teamId=0,
                                squad=0)
        self.reg = FakeClient(self.console,
                              name="Reg",
                              exactName="Reg",
                              guid="qsdfdsqfdsqf33",
                              groupBits=4,
                              team=TEAM_UNKNOWN,
                              teamId=0,
                              squad=0)
        self.moderator = FakeClient(self.console,
                                    name="Moderator",
                                    exactName="Moderator",
                                    guid="sdf455ezr",
                                    groupBits=8,
                                    team=TEAM_UNKNOWN,
                                    teamId=0,
                                    squad=0)
        self.admin = FakeClient(self.console,
                                name="Level-40-Admin",
                                exactName="Level-40-Admin",
                                guid="875sasda",
                                groupBits=16,
                                team=TEAM_UNKNOWN,
                                teamId=0,
                                squad=0)
        self.superadmin = FakeClient(self.console,
                                     name="God",
                                     exactName="God",
                                     guid="f4qfer654r",
                                     groupBits=128,
                                     team=TEAM_UNKNOWN,
                                     teamId=0,
                                     squad=0)
Example #18
0
 def data(self, value):
     try:
         self._data = Bf3Parser.decodeServerinfo(value)
     except Exception, err:
         self.console.error(err)
         self._data = None
Example #19
0
    def test_decodeServerinfo_pre_R9(self):
        self.assertDictContainsSubset(
            {
                'serverName': 'BigBrotherBot #2',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'ConquestLarge0',
                'level': 'MP_012',
                'roundsPlayed': '0',
                'roundsTotal': '2',
                'numTeams': '0',
                'team1score': None,
                'team2score': None,
                'team3score': None,
                'team4score': None,
                'targetScore': '0',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '5148',
                'roundTime': '455',
            },
            Bf3Parser.decodeServerinfo(
                ('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012',
                 '0', '2', '0', '0', '', 'true', 'true', 'false', '5148',
                 '455')))

        self.assertDictContainsSubset(
            {
                'serverName': 'BigBrotherBot #2',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'ConquestLarge0',
                'level': 'MP_012',
                'roundsPlayed': '0',
                'roundsTotal': '2',
                'numTeams': '1',
                'team1score': '47',
                'team2score': None,
                'team3score': None,
                'team4score': None,
                'targetScore': '0',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '5148',
                'roundTime': '455',
            },
            Bf3Parser.decodeServerinfo(
                ('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012',
                 '0', '2', '1', '47', '0', '', 'true', 'true', 'false', '5148',
                 '455')))

        self.assertDictContainsSubset(
            {
                'serverName': 'BigBrotherBot #2',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'ConquestLarge0',
                'level': 'MP_012',
                'roundsPlayed': '0',
                'roundsTotal': '2',
                'numTeams': '2',
                'team1score': '300',
                'team2score': '300',
                'team3score': None,
                'team4score': None,
                'targetScore': '0',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '5148',
                'roundTime': '455',
            },
            Bf3Parser.decodeServerinfo(
                ('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012',
                 '0', '2', '2', '300', '300', '0', '', 'true', 'true', 'false',
                 '5148', '455')))

        self.assertDictContainsSubset(
            {
                'serverName': 'BigBrotherBot #2',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'ConquestLarge0',
                'level': 'MP_012',
                'roundsPlayed': '1',
                'roundsTotal': '2',
                'numTeams': '3',
                'team1score': '300',
                'team2score': '215',
                'team3score': '25',
                'team4score': None,
                'targetScore': '0',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '5148',
                'roundTime': '455',
            },
            Bf3Parser.decodeServerinfo(
                ('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012',
                 '1', '2', '3', '300', '215', '25', '0', '', 'true', 'true',
                 'false', '5148', '455')))

        self.assertDictContainsSubset(
            {
                'serverName': 'BigBrotherBot #2',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'ConquestLarge0',
                'level': 'MP_012',
                'roundsPlayed': '1',
                'roundsTotal': '2',
                'numTeams': '4',
                'team1score': '300',
                'team2score': '215',
                'team3score': '25',
                'team4score': '84',
                'targetScore': '0',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '5148',
                'roundTime': '455',
            },
            Bf3Parser.decodeServerinfo(
                ('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012',
                 '1', '2', '4', '300', '215', '25', '84', '0', '', 'true',
                 'true', 'false', '5148', '455')))
Example #20
0
    def test_decodeServerinfo_pre_R9(self):
        self.assertDictContainsSubset({
            'serverName': 'BigBrotherBot #2',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'ConquestLarge0',
            'level': 'MP_012',
            'roundsPlayed': '0',
            'roundsTotal': '2',
            'numTeams': '0',
            'team1score': None,
            'team2score': None,
            'team3score': None,
            'team4score': None,
            'targetScore': '0',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '5148',
            'roundTime': '455',
        }, Bf3Parser.decodeServerinfo(('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012', '0', '2', '0', '0', '', 'true', 'true', 'false', '5148', '455')))

        self.assertDictContainsSubset({
            'serverName': 'BigBrotherBot #2',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'ConquestLarge0',
            'level': 'MP_012',
            'roundsPlayed': '0',
            'roundsTotal': '2',
            'numTeams': '1',
            'team1score': '47',
            'team2score': None,
            'team3score': None,
            'team4score': None,
            'targetScore': '0',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '5148',
            'roundTime': '455',
        }, Bf3Parser.decodeServerinfo(('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012', '0', '2', '1', '47', '0', '', 'true', 'true', 'false', '5148', '455')))

        self.assertDictContainsSubset({
            'serverName': 'BigBrotherBot #2',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'ConquestLarge0',
            'level': 'MP_012',
            'roundsPlayed': '0',
            'roundsTotal': '2',
            'numTeams': '2',
            'team1score': '300',
            'team2score': '300',
            'team3score': None,
            'team4score': None,
            'targetScore': '0',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '5148',
            'roundTime': '455',
        }, Bf3Parser.decodeServerinfo(('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012', '0', '2', '2', '300', '300', '0', '', 'true', 'true', 'false', '5148', '455')))

        self.assertDictContainsSubset({
            'serverName': 'BigBrotherBot #2',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'ConquestLarge0',
            'level': 'MP_012',
            'roundsPlayed': '1',
            'roundsTotal': '2',
            'numTeams': '3',
            'team1score': '300',
            'team2score': '215',
            'team3score': '25',
            'team4score': None,
            'targetScore': '0',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '5148',
            'roundTime': '455',
        }, Bf3Parser.decodeServerinfo(('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012', '1', '2', '3', '300', '215', '25', '0', '', 'true', 'true', 'false', '5148', '455')))

        self.assertDictContainsSubset({
            'serverName': 'BigBrotherBot #2',
            'numPlayers': '0',
            'maxPlayers': '16',
            'gamemode': 'ConquestLarge0',
            'level': 'MP_012',
            'roundsPlayed': '1',
            'roundsTotal': '2',
            'numTeams': '4',
            'team1score': '300',
            'team2score': '215',
            'team3score': '25',
            'team4score': '84',
            'targetScore': '0',
            'onlineState': '',
            'isRanked': 'true',
            'hasPunkbuster': 'true',
            'hasPassword': '******',
            'serverUptime': '5148',
            'roundTime': '455',
        }, Bf3Parser.decodeServerinfo(('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012', '1', '2', '4', '300', '215', '25', '84', '0', '', 'true', 'true', 'false', '5148', '455')))
Example #21
0
 def setUp(self):
     with logging_disabled():
         self.conf = CfgConfigParser()
         self.parser = Bf3Parser(self.conf)
Example #22
0
    def test_decodeServerinfo_R9(self):
        self.maxDiff = None
        self.assertDictEqual(
            {
                'serverName': 'BigBrotherBot #2',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'ConquestLarge0',
                'level': 'MP_012',
                'roundsPlayed': '0',
                'roundsTotal': '2',
                'numTeams': '0',
                'team1score': None,
                'team2score': None,
                'team3score': None,
                'team4score': None,
                'targetScore': '0',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '5148',
                'roundTime': '455',
                'gameIpAndPort': '1.2.3.4:5445',
                'punkBusterVersion': '1.5',
                'joinQueueEnabled': 'false',
                'region': 'EU',
                'closestPingSite': '45',
                'country': 'FR',
            },
            Bf3Parser.decodeServerinfo(
                ('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012',
                 '0', '2', '0', '0', '', 'true', 'true', 'false', '5148',
                 '455', '1.2.3.4:5445', '1.5', 'false', 'EU', '45', 'FR')))

        self.assertDictEqual(
            {
                'serverName': 'BigBrotherBot #2',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'ConquestLarge0',
                'level': 'MP_012',
                'roundsPlayed': '0',
                'roundsTotal': '2',
                'numTeams': '1',
                'team1score': '47',
                'team2score': None,
                'team3score': None,
                'team4score': None,
                'targetScore': '0',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '5148',
                'roundTime': '455',
                'gameIpAndPort': '1.2.3.4:5445',
                'punkBusterVersion': '1.5',
                'joinQueueEnabled': 'false',
                'region': 'EU',
                'closestPingSite': '45',
                'country': 'FR',
            },
            Bf3Parser.decodeServerinfo(
                ('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012',
                 '0', '2', '1', '47', '0', '', 'true', 'true', 'false', '5148',
                 '455', '1.2.3.4:5445', '1.5', 'false', 'EU', '45', 'FR')))

        self.assertDictEqual(
            {
                'serverName': 'BigBrotherBot #2',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'ConquestLarge0',
                'level': 'MP_012',
                'roundsPlayed': '0',
                'roundsTotal': '2',
                'numTeams': '2',
                'team1score': '300',
                'team2score': '300',
                'team3score': None,
                'team4score': None,
                'targetScore': '0',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '5148',
                'roundTime': '455',
                'gameIpAndPort': '1.2.3.4:5445',
                'punkBusterVersion': '1.5',
                'joinQueueEnabled': 'false',
                'region': 'EU',
                'closestPingSite': '45',
                'country': 'FR',
            },
            Bf3Parser.decodeServerinfo(
                ('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012',
                 '0', '2', '2', '300', '300', '0', '', 'true', 'true', 'false',
                 '5148', '455', '1.2.3.4:5445', '1.5', 'false', 'EU', '45',
                 'FR')))

        self.assertDictEqual(
            {
                'serverName': 'BigBrotherBot #2',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'ConquestLarge0',
                'level': 'MP_012',
                'roundsPlayed': '1',
                'roundsTotal': '2',
                'numTeams': '3',
                'team1score': '300',
                'team2score': '215',
                'team3score': '25',
                'team4score': None,
                'targetScore': '0',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '5148',
                'roundTime': '455',
                'gameIpAndPort': '1.2.3.4:5445',
                'punkBusterVersion': '1.5',
                'joinQueueEnabled': 'false',
                'region': 'EU',
                'closestPingSite': '45',
                'country': 'FR',
            },
            Bf3Parser.decodeServerinfo(
                ('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012',
                 '1', '2', '3', '300', '215', '25', '0', '', 'true', 'true',
                 'false', '5148', '455', '1.2.3.4:5445', '1.5', 'false', 'EU',
                 '45', 'FR')))

        self.assertDictEqual(
            {
                'serverName': 'BigBrotherBot #2',
                'numPlayers': '0',
                'maxPlayers': '16',
                'gamemode': 'ConquestLarge0',
                'level': 'MP_012',
                'roundsPlayed': '1',
                'roundsTotal': '2',
                'numTeams': '4',
                'team1score': '300',
                'team2score': '215',
                'team3score': '25',
                'team4score': '84',
                'targetScore': '0',
                'onlineState': '',
                'isRanked': 'true',
                'hasPunkbuster': 'true',
                'hasPassword': '******',
                'serverUptime': '5148',
                'roundTime': '455',
                'gameIpAndPort': '1.2.3.4:5445',
                'punkBusterVersion': '1.5',
                'joinQueueEnabled': 'false',
                'region': 'EU',
                'closestPingSite': '45',
                'country': 'FR',
            },
            Bf3Parser.decodeServerinfo(
                ('BigBrotherBot #2', '0', '16', 'ConquestLarge0', 'MP_012',
                 '1', '2', '4', '300', '215', '25', '84', '0', '', 'true',
                 'true', 'false', '5148', '455', '1.2.3.4:5445', '1.5',
                 'false', 'EU', '45', 'FR')))
    def setUp(self):
        # create a BF3 parser
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString("""<configuration />""")
        with logging_disabled():
            self.console = Bf3Parser(self.parser_conf)

        # alter a few settings to speed up the tests
        self.console.sayqueue_get_timeout = 0
        self.console._message_delay = 0

        with logging_disabled():
            self.console.startup()

        # load the admin plugin
        with logging_disabled():
            self.adminPlugin = AdminPlugin(self.console,
                                           '@b3/conf/plugin_admin.ini')
            self.adminPlugin.onStartup()

        # make sure the admin plugin obtained by other plugins is our admin plugin
        def getPlugin(name):
            if name == 'admin':
                return self.adminPlugin
            else:
                return self.console.getPlugin(name)

        self.console.getPlugin = getPlugin

        self.console.patch_b3_admin_plugin()

        # prepare a few players
        with logging_disabled():
            from b3.fake import FakeClient
            self.joe = FakeClient(self.console,
                                  name="Joe",
                                  exactName="Joe",
                                  guid="zaerezarezar",
                                  groupBits=1,
                                  team=TEAM_UNKNOWN,
                                  teamId=0,
                                  squad=0)
            self.simon = FakeClient(self.console,
                                    name="Simon",
                                    exactName="Simon",
                                    guid="qsdfdsqfdsqf",
                                    groupBits=0,
                                    team=TEAM_UNKNOWN,
                                    teamId=0,
                                    squad=0)
            self.reg = FakeClient(self.console,
                                  name="Reg",
                                  exactName="Reg",
                                  guid="qsdfdsqfdsqf33",
                                  groupBits=4,
                                  team=TEAM_UNKNOWN,
                                  teamId=0,
                                  squad=0)
            self.moderator = FakeClient(self.console,
                                        name="Moderator",
                                        exactName="Moderator",
                                        guid="sdf455ezr",
                                        groupBits=8,
                                        team=TEAM_UNKNOWN,
                                        teamId=0,
                                        squad=0)
            self.admin = FakeClient(self.console,
                                    name="Level-40-Admin",
                                    exactName="Level-40-Admin",
                                    guid="875sasda",
                                    groupBits=16,
                                    team=TEAM_UNKNOWN,
                                    teamId=0,
                                    squad=0)
            self.superadmin = FakeClient(self.console,
                                         name="God",
                                         exactName="God",
                                         guid="f4qfer654r",
                                         groupBits=128,
                                         team=TEAM_UNKNOWN,
                                         teamId=0,
                                         squad=0)
 def data(self, value):
     try:
         self._data = Bf3Parser.decodeServerinfo(value)
     except Exception, err:
         self.console.error(err)
         self._data = None