예제 #1
0
    def setUp(self):
        super(Test_autoassign, self).setUp()
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""
[preferences]
no_autoassign_level: 20
autoassign: On
team_swap_threshold: 2
        """)
        with logging_disabled():
            self.p = Poweradminbf3Plugin(self.console, self.conf)
            self.p.onLoadConfig()
            self.p.onStartup()
        self.assertTrue(self.p._autoassign)
        self.assertEqual(20, self.p._no_autoassign_level)

        def my_write(data):
            if data[0] == 'admin.movePlayer':
                self.console.routeFrostbitePacket(
                    ['player.onTeamChange', data[1], data[2], data[3]])
                return ['OK']
            else:
                return Mock()

        self.write_patcher = patch.object(self.console,
                                          "write",
                                          side_effect=my_write)
        self.write_mock = self.write_patcher.start()
 def setUp(self):
     self.available_names = [
         "hardcore", "normal", "infantry", "tdm", "conquest", "rush",
         "quickmatch", "hardcore-tdm", "hardcore-conquest"
     ]
     self.console = Mock()
     self.p = Poweradminbf3Plugin(self.console)
     self.p._list_available_server_config_files = lambda: self.available_names
예제 #3
0
    def setUp(self):
        super(Test_cmd_swap, self).setUp()
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
swap: 20
        """)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
    def setUp(self):
        Bf3TestCase.setUp(self)
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
vehicles: 20
        """)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
예제 #5
0
    def assert_config_value(self, expected, conf_value):
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""
[preferences]
team_swap_threshold: %s
                    """ % conf_value)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.assertEqual(expected, self.p._team_swap_threshold)
    def test_yell_duration_empty(self):
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""
[preferences]
yell_duration:
        """)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.assertEqual(10, self.p._yell_duration)
예제 #7
0
    def setUp(self):
        Bf3TestCase.setUp(self)
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
roundnext: 20
        """)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
        self.superadmin.connects('superadmin')
    def setUp(self):
        super(Test_cmd_unlockmode, self).setUp()
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
unlockmode: 40
        """)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
        when(self.console).write()
예제 #9
0
    def setUp(self):
        Bf3TestCase.setUp(self)
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
vipload: 20
        """)
        with logging_disabled():
            self.p = Poweradminbf3Plugin(self.console, self.conf)
            self.p.onLoadConfig()
            self.p.onStartup()
            self.moderator.connects("moderator")
    def setUp(self):
        super(Test_cmd_autobalance, self).setUp()
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""
[commands]
autobalance: mod
""")
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
        self.p.console._cron = Mock()
    def setUp(self):
        Bf3TestCase.setUp(self)
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
yell: 20

[preferences]
yell_duration: 2
        """)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
예제 #12
0
    def setUp(self):
        super(Test_issue_14, self).setUp()
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
swap: 0

[preferences]
no_level_check_level: 20
        """)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
 def setUp(self):
     Bf3TestCase.setUp(self)
     self.conf = CfgConfigParser()
     with logging_disabled():
         self.p = Poweradminbf3Plugin(self.console, self.conf)
     when(self.console).write(
         ('vars.roundStartPlayerCount', )).thenReturn(['0'])
     when(self.console).write(
         ('vars.roundLockdownCountdown', )).thenReturn(['3'])
     self.scrambleTeams_mock = self.p._scrambler.scrambleTeams = Mock(
         name="scrambleTeams", wraps=self.p._scrambler.scrambleTeams)
     self.scrambleTeams_mock.reset_mock()
    def setUp(self):
        Bf3TestCase.setUp(self)
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
scramblemode: 20
        """)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
        self.p._scrambler = Mock()
        self.superadmin.connects('superadmin')
        self.superadmin.clearMessageHistory()
    def setUp(self):
        super(Test_cmd_idle, self).setUp()
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
idle: 40
        """)
        with logging_disabled():
            self.p = Poweradminbf3Plugin(self.console, self.conf)
            self.p.onLoadConfig()
            self.p.onStartup()

        self.p.error = Mock(wraps=self.p.error)
        logging.getLogger('output').setLevel(logging.DEBUG)
    def setUp(self):
        super(Test_cmd_setnextmap, self).setUp()
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
setnextmap-snmap: 20
        """)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        logging.getLogger('output').setLevel(logging.DEBUG)
        self.console.game.gameType = 'ConquestSmall0'
        self.console.game.serverinfo = {'roundsTotal': 2}
    def setUp(self):
        super(Test_cmd_listconfig, self).setUp()
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
listconfig: 40

[preferences]
config_path: %(script_dir)s
            """ % {'script_dir': os.path.abspath(
            os.path.join(os.path.dirname(__file__), '../extplugins/conf/serverconfigs'))})
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
        self.admin.connects("admin")
        self.admin.clearMessageHistory()
예제 #18
0
    def setUp(self):
        Bf3TestCase.setUp(self)
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
viplist: 20
        """)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        self.console.say = Mock()
        self.console.saybig = Mock()

        self.moderator.connects("moderator")

        self.joe.connects('joe')
        self.joe.teamId = 2
    def setUp(self):
        super(Test_cmd_changeteam, self).setUp()
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""
[commands]
changeteam: mod
        """)
        with logging_disabled():
            self.p = Poweradminbf3Plugin(self.console, self.conf)
            self.p.onLoadConfig()
            self.p.onStartup()

        def my_write(data):
            if data[0] == 'admin.movePlayer':
                self.console.routeFrostbitePacket(['player.onTeamChange', data[1], data[2], data[3]])
                return ['OK']
            else:
                return Mock()

        self.write_patcher = patch.object(self.console, "write", side_effect=my_write)
        self.write_mock = self.write_patcher.start()
예제 #20
0
    def setUp(self):
        Bf3TestCase.setUp(self)
        self.conf = CfgConfigParser()
        self.conf.loadFromString("""[commands]
nuke: 20
        """)
        self.p = Poweradminbf3Plugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        self.sleep_patcher = patch.object(time, 'sleep')
        self.sleep_patcher.start()

        self.console.write = Mock()
        self.console.say = Mock()
        self.console.saybig = Mock()

        self.moderator.connects("moderator")
        self.moderator.teamId = 1

        self.joe.connects('joe')
        self.joe.teamId = 2
예제 #21
0
 def test_default_value(self):
     self.conf = CfgConfigParser()
     self.conf.loadFromString("""[foo]""")
     self.p = Poweradminbf3Plugin(self.console, self.conf)
     self.p.onLoadConfig()
     self.assertEqual(self.default_value, self.p._team_swap_threshold)
예제 #22
0
 def setUp(self):
     self.console = Mock()
     self.p = Poweradminbf3Plugin(self.console)
예제 #23
0
 def setUp(self):
     Bf3TestCase.setUp(self)
     self.conf = CfgConfigParser()
     self.p = Poweradminbf3Plugin(self.console, self.conf)
     logger = logging.getLogger('output')
     logger.setLevel(logging.INFO)