Example #1
0
 def setUp(self):
     self.conf = XmlConfigParser()
     self.conf.loadFromString("""
             <configuration>
             </configuration>
         """)
     self.parser = Bf3Parser(self.conf)
     self.parser.startup()
Example #2
0
 def setUp(self):
     BF3TestCase.setUp(self)
     self.conf = XmlConfigParser()
     self.conf.loadFromString("""
             <configuration>
             </configuration>
         """)
     self.parser = Bf3Parser(self.conf)
Example #3
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 #4
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 #5
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 #6
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 #7
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}
    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)
Example #9
0
 def setUp(self):
     with logging_disabled():
         self.conf = CfgConfigParser()
         self.parser = Bf3Parser(self.conf)
Example #10
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)