当前位置: 首页>>代码示例>>Python>>正文


Python AdminPlugin.onStartup方法代码示例

本文整理汇总了Python中b3.plugins.admin.AdminPlugin.onStartup方法的典型用法代码示例。如果您正苦于以下问题:Python AdminPlugin.onStartup方法的具体用法?Python AdminPlugin.onStartup怎么用?Python AdminPlugin.onStartup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在b3.plugins.admin.AdminPlugin的用法示例。


在下文中一共展示了AdminPlugin.onStartup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PluginmanagerTestCase

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class PluginmanagerTestCase(B3TestCase):

    def setUp(self):

        B3TestCase.setUp(self)
        self.console.gameName = 'f00'

        self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini')
        when(self.console).getPlugin("admin").thenReturn(self.adminPlugin)
        self.adminPlugin.onLoadConfig()
        self.adminPlugin.onStartup()

        self.conf = CfgConfigParser()
        self.conf.loadFromString(dedent(r"""
            [commands]
            plugin: superadmin
        """))

        self.p = PluginmanagerPlugin(self.console, self.conf)
        when(self.console).getPlugin("pluginmanager").thenReturn(self.adminPlugin)
        self.p.onLoadConfig()
        self.p.onStartup()

        when(self.console.config).get_external_plugins_dir().thenReturn(b3.getAbsolutePath('@b3\\extplugins'))

        # store them also in the console _plugins dict
        self.console._plugins['admin'] = self.adminPlugin
        self.console._plugins['pluginmanager'] = self.p

    def tearDown(self):
        self.console._plugins.clear()
        B3TestCase.tearDown(self)
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:34,代码来源:__init__.py

示例2: CustomcommandsTestCase

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class CustomcommandsTestCase(unittest2.TestCase):

    def setUp(self):
        self.sleep_patcher = patch("time.sleep")
        self.sleep_mock = self.sleep_patcher.start()

        # create a FakeConsole parser
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString(r"""<configuration/>""")
        with logging_disabled():
            from b3.fake import FakeConsole
            self.console = FakeConsole(self.parser_conf)

        with logging_disabled():
            self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini')
            self.adminPlugin._commands = {}  # work around known bug in the Admin plugin which makes the _command property shared between all instances
            self.adminPlugin.onStartup()

        # make sure the admin plugin obtained by other plugins is our admin plugin
        when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)

        self.console.screen = Mock()
        self.console.time = time.time
        self.console.upTime = Mock(return_value=3)

        self.console.cron.stop()

    def tearDown(self):
        self.sleep_patcher.stop()
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:31,代码来源:__init__.py

示例3: ProxyfilterTestCase

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class ProxyfilterTestCase(unittest2.TestCase):

    def setUp(self):
        # create a FakeConsole parser
        self.parser_conf = MainConfig(CfgConfigParser(allow_no_value=True))
        self.parser_conf.loadFromString(r"""""")
        with logging_disabled():
            from b3.fake import FakeConsole
            self.console = FakeConsole(self.parser_conf)

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

        # make sure the admin plugin obtained by other plugins is our admin plugin
        when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)
        when(self.console.config).get_external_plugins_dir().thenReturn(os.path.join(os.getcwd(), '..', '..'))

        # patch the Proxyfilter class not to execute
        # proxy scans in a multithreaded environment
        patch_proxy_filter()

    def tearDown(self):
        self.console.working = False
开发者ID:danielepantaleone,项目名称:b3-plugin-proxyfilter,代码行数:28,代码来源:__init__.py

示例4: setUp

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
    def setUp(self):
        B3TestCase.setUp(self)

        with logging_disabled():
            admin_conf = CfgConfigParser()
            admin_plugin = AdminPlugin(self.console, admin_conf)
            admin_plugin.onLoadConfig()
            admin_plugin.onStartup()
            when(self.console).getPlugin('admin').thenReturn(admin_plugin)

        conf = CfgConfigParser()
        conf.loadFromString(dedent(r"""
            [commands]
            mapstats-stats: 0
            testscore-ts: 0
            topstats-top: 0
            topxp: 0

            [settings]
            startPoints: 100
            resetscore: no
            resetxp: no
            show_awards: no
            show_awards_xp: no
        """))
        self.p = StatsPlugin(self.console, conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        self.joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=1, team=TEAM_RED)
        self.mike = FakeClient(self.console, name="Mike", guid="mikeguid", groupBits=1, team=TEAM_RED)
        self.joe.connects(1)
        self.mike.connects(2)
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:35,代码来源:__init__.py

示例5: Welcome_functional_test

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class Welcome_functional_test(B3TestCase):

    def setUp(self):

        B3TestCase.setUp(self)

        with logging_disabled():
            self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini')
            when(self.console).getPlugin("admin").thenReturn(self.adminPlugin)
            self.adminPlugin.onLoadConfig()
            self.adminPlugin.onStartup()

            self.conf = CfgConfigParser()
            self.p = WelcomePlugin(self.console, self.conf)

            self.joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=1, team=b3.TEAM_RED)
            self.mike = FakeClient(self.console, name="Mike", guid="mikeguid", groupBits=1, team=b3.TEAM_RED)
            self.bill = FakeClient(self.console, name="Bill", guid="billguid", groupBits=1, team=b3.TEAM_RED)
            self.superadmin = FakeClient(self.console, name="SuperAdmin", guid="superadminguid", groupBits=128, team=b3.TEAM_RED)

    def load_config(self, config_content=None):
        """
        load the given config content, or the default config if config_content is None.
        """
        if config_content is None:
            self.conf.load(b3.getAbsolutePath('@b3/conf/plugin_welcome.ini'))
        else:
            self.conf.loadFromString(config_content)
        self.p.onLoadConfig()
        self.p.onStartup()
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:32,代码来源:__init__.py

示例6: ChatloggerTestCase

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class ChatloggerTestCase(unittest.TestCase):

    def setUp(self):
        testcase_lock.acquire()
        self.addCleanup(cleanUp)
        flush_console_streams()
        # create a FakeConsole parser
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString(r"""<configuration/>""")
        with logging_disabled():
            from b3.fake import FakeConsole
            self.console = FakeConsole(self.parser_conf)

        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
        when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)

        self.console.screen = Mock()
        self.console.time = time.time
        self.console.upTime = Mock(return_value=3)

    def tearDown(self):
        try:
            self.console.storage.shutdown()
        except:
            pass
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:31,代码来源:__init__.py

示例7: Iourt41TestCase

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class Iourt41TestCase(Iourt41_TestCase_mixin):
    """
    Test case that is suitable for testing Iourt41 parser specific features
    """

    def setUp(self):
        # create a Iourt41 parser
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString("""<configuration><settings name="server"><set name="game_log"></set></settings></configuration>""")
        self.console = Iourt41Parser(self.parser_conf)

        self.console.write = Mock(name="write", side_effect=write)
        self.console.startup()


        # load the admin plugin
        if B3version(b3_version) >= B3version("1.10dev"):
            admin_plugin_conf_file = '@b3/conf/plugin_admin.ini'
        else:
            admin_plugin_conf_file = '@b3/conf/plugin_admin.xml'
        self.adminPlugin = AdminPlugin(self.console, admin_plugin_conf_file)
    	self.adminPlugin.onLoadConfig()
    	self.adminPlugin.onStartup()

        # make sure the admin plugin obtained by other plugins is our admin plugin
        when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)


    def tearDown(self):
        self.console.working = False
开发者ID:thomasleveil,项目名称:b3-plugin-urt-serverside-demo,代码行数:32,代码来源:__init__.py

示例8: DuelTestCase

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class DuelTestCase(unittest2.TestCase):

    def setUp(self):
        console_conf = CfgConfigParser()
        console_conf.loadFromString(r'''''')
        self.console_main_conf = MainConfig(console_conf)

        with logging_disabled():
            from b3.fake import FakeConsole
            self.console = FakeConsole(self.console_main_conf)

        with logging_disabled():
            self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini')
            self.adminPlugin._commands = {}
            self.adminPlugin.onStartup()

        # make sure the admin plugin obtained by other plugins is our admin plugin
        when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)

        # create our plugin instance
        self.p = DuelPlugin(self.console)
        self.p.onStartup()

        with logging_disabled():
            from b3.fake import FakeClient

        self.mike = FakeClient(console=self.console, name="Mike", guid="MIKEGUID", groupBits=1)
        self.bill = FakeClient(console=self.console, name="Bill", guid="BILLGUID", groupBits=1)
        self.anna = FakeClient(console=self.console, name="Anna", guid="ANNAGUID", groupBits=1)

    def tearDown(self):
        unstub()
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:34,代码来源:__init__.py

示例9: Admin_functional_test

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class Admin_functional_test(B3TestCase):
    """ tests from a class inherithing from Admin_functional_test must call self.init() """

    def setUp(self):
        B3TestCase.setUp(self)
        self.conf = XmlConfigParser()
        self.p = AdminPlugin(self.console, self.conf)

    def init(self, config_content=None):
        """ optionally specify a config for the plugin. If called with no parameter, then the default config is loaded """
        if config_content is None:
            if not os.path.isfile(ADMIN_CONFIG_FILE):
                B3TestCase.tearDown(self)  # we are skipping the test at a late stage after setUp was called
                raise unittest.SkipTest("%s is not a file" % ADMIN_CONFIG_FILE)
            else:
                self.conf.load(ADMIN_CONFIG_FILE)
        else:
            self.conf.loadFromString(config_content)
        self.p.onLoadConfig()
        self.p.onStartup()

        self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="joeguid", groupBits=128, team=TEAM_RED)
        self.mike = FakeClient(
            self.console, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=TEAM_BLUE
        )
开发者ID:derfull,项目名称:big-brother-bot,代码行数:27,代码来源:test_admin_functional.py

示例10: CalladminTestCase

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class CalladminTestCase(unittest2.TestCase):

    def setUp(self):
        self.sleep_patcher = patch("time.sleep")
        self.sleep_mock = self.sleep_patcher.start()

        # create a FakeConsole parser
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString(r"""<configuration/>""")
        with logging_disabled():
            from b3.fake import FakeConsole
            self.console = FakeConsole(self.parser_conf)

        with logging_disabled():
            self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini')
            self.adminPlugin._commands = {}
            self.adminPlugin.onStartup()

        # make sure the admin plugin obtained by other plugins is our admin plugin
        when(self.console).getCvar('sv_hostname').thenReturn(Cvar(name='sv_hostname', value='Test Server'))
        when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)
        when(time).time().thenReturn(60)

    def tearDown(self):
        self.sleep_patcher.stop()
开发者ID:danielepantaleone,项目名称:b3-plugin-calladmin,代码行数:27,代码来源:__init__.py

示例11: PluginTestCase

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class PluginTestCase(unittest.TestCase):

    def setUp(self):
        # less logging
        logging.getLogger('output').setLevel(logging.ERROR)

        # create a parser
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString("""<configuration></configuration>""")
        self.console = DummyParser(self.parser_conf)
        self.console.startup()

        # load the admin plugin
        if B3version(b3_version) >= B3version("1.10dev"):
            admin_plugin_conf_file = '@b3/conf/plugin_admin.ini'
        else:
            admin_plugin_conf_file = '@b3/conf/plugin_admin.xml'
        with logging_disabled():
            self.adminPlugin = AdminPlugin(self.console, admin_plugin_conf_file)
            self.adminPlugin.onStartup()

        # make sure the admin plugin obtained by other plugins is our admin plugin
        when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)


        # prepare a few players
        self.joe = FakeClient(self.console, name="Joe", guid="joe_guid", groupBits=1)
        self.simon = FakeClient(self.console, name="Simon", guid="simon_guid", groupBits=0)
        self.moderator = FakeClient(self.console, name="Moderator", guid="moderator_guid", groupBits=8)

        logging.getLogger('output').setLevel(logging.DEBUG)


    def tearDown(self):
        self.console.working = False
开发者ID:thomasleveil,项目名称:b3-plugin-vacban,代码行数:37,代码来源:__init__.py

示例12: Iourt41TestCase

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class Iourt41TestCase(unittest.TestCase):
    """
    Test case that is suitable for testing iourt41 parser specific features
    """

    @classmethod
    def setUpClass(cls):
        # less logging
        logging.getLogger('output').setLevel(logging.CRITICAL)

        from b3.parsers.q3a.abstractParser import AbstractParser
        from b3.fake import FakeConsole
        AbstractParser.__bases__ = (FakeConsole,)
        # Now parser inheritance hierarchy is :
        # Iourt41Parser -> AbstractParser -> FakeConsole -> Parser


    def setUp(self):
        # create a BF3 parser
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString("""
            <configuration>
                <settings name="messages">
                <set name="kicked_by">$clientname was kicked by $adminname $reason</set>
                <set name="kicked">$clientname was kicked $reason</set>
                <set name="banned_by">$clientname was banned by $adminname $reason</set>
                <set name="banned">$clientname was banned $reason</set>
                <set name="temp_banned_by">$clientname was temp banned by $adminname for $banduration $reason</set>
                <set name="temp_banned">$clientname was temp banned for $banduration $reason</set>
                <set name="unbanned_by">$clientname was un-banned by $adminname $reason</set>
                <set name="unbanned">$clientname was un-banned $reason</set>
            </settings>
            </configuration>
        """)
        self.console = Iourt41Parser(self.parser_conf)
        self.console.startup()

        # 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

        # prepare a few players
        self.joe = FakeClient(self.console, name="Joe", guid="00000000000000000000000000000001", groupBits=1, team=TEAM_UNKNOWN)
        self.simon = FakeClient(self.console, name="Simon", guid="00000000000000000000000000000002", groupBits=0, team=TEAM_UNKNOWN)
        self.reg = FakeClient(self.console, name="Reg", guid="00000000000000000000000000000003", groupBits=4, team=TEAM_UNKNOWN)
        self.moderator = FakeClient(self.console, name="Moderator", guid="00000000000000000000000000000004", groupBits=8, team=TEAM_UNKNOWN)
        self.admin = FakeClient(self.console, name="Level-40-Admin", guid="00000000000000000000000000000005", groupBits=16, team=TEAM_UNKNOWN)
        self.superadmin = FakeClient(self.console, name="God", guid="00000000000000000000000000000000", groupBits=128, team=TEAM_UNKNOWN)

        # more logging
        logging.getLogger('output').setLevel(logging.DEBUG)
开发者ID:danielepantaleone,项目名称:b3-plugin-haxbusterurt,代码行数:61,代码来源:__init__.py

示例13: MapcycleTestCase

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class MapcycleTestCase(unittest2.TestCase):

    @classmethod
    def setUpClass(cls):
        with logging_disabled():
            from b3.parsers.q3a.abstractParser import AbstractParser
            from b3.fake import FakeConsole
            AbstractParser.__bases__ = (FakeConsole,)
            # Now parser inheritance hierarchy is :
            # Iourt41Parser -> abstractParser -> FakeConsole -> Parser

    def setUp(self):
        # create a Iourt42 parser
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString(dedent(r"""
            <configuration>
                <settings name="server">
                    <set name="game_log"></set>
                </settings>
            </configuration>
            """))

        self.console = Iourt42Parser(self.parser_conf)

        # initialize some fixed cvars which will be used by both the plugin and the iourt42 parser
        when(self.console).getCvar('auth').thenReturn(Cvar('auth', value='0'))
        when(self.console).getCvar('fs_basepath').thenReturn(Cvar('g_maxGameClients', value='/fake/basepath'))
        when(self.console).getCvar('fs_homepath').thenReturn(Cvar('sv_maxclients', value='/fake/homepath'))
        when(self.console).getCvar('fs_game').thenReturn(Cvar('fs_game', value='q3ut4'))
        when(self.console).getCvar('gamename').thenReturn(Cvar('gamename', value='q3urt42'))

        # start the parser
        self.console.startup()

        with logging_disabled():
            self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini')
            self.adminPlugin.onLoadConfig()
            self.adminPlugin.onStartup()

        # make sure the admin plugin obtained by other plugins is our admin plugin
        when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)

        # force fake mapname here so Mapcycle Plugin will
        # not catch useless EVT_GAME_MAP_CHANGE
        self.console.game.mapName = 'ut4_casa'

        self.conf = XmlConfigParser()
        self.conf.loadFromString(dedent(MAPCYCLE_PLUGIN_CONFIG))

        # patch the mapcycle plugin for testing purpose
        patch_mapcycle_plugin()

        self.p = MapcyclePlugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()

    def tearDown(self):
        self.console.working = False
开发者ID:danielepantaleone,项目名称:b3-plugin-mapcycle,代码行数:60,代码来源:__init__.py

示例14: Iourt41TestCase

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class Iourt41TestCase(unittest.TestCase):
    """
    Test case that is suitable for testing Iourt41 parser specific features
    """

    @classmethod
    def setUpClass(cls):

        with logging_disabled():
            from b3.parsers.q3a.abstractParser import AbstractParser
            from b3.fake import FakeConsole
            AbstractParser.__bases__ = (FakeConsole,)
            # Now parser inheritance hierarchy is :
            # Iourt41Parser -> abstractParser -> FakeConsole -> Parser

    def setUp(self):

        with logging_disabled():
            # create a Iourt41 parser
            self.parser_conf = XmlConfigParser()
            self.parser_conf.loadFromString("""<configuration><settings name="server"><set name="game_log"></set></settings></configuration>""")
            self.console = Iourt41Parser(self.parser_conf)
            self.console.startup()

            # load the admin plugin
            if B3version(b3_version) >= B3version("1.10dev"):
                admin_plugin_conf_file = '@b3/conf/plugin_admin.ini'
            else:
                admin_plugin_conf_file = '@b3/conf/plugin_admin.xml'
            with logging_disabled():
                self.adminPlugin = AdminPlugin(self.console, admin_plugin_conf_file)
                self.adminPlugin.onLoadConfig()
                self.adminPlugin.onStartup()

            # make sure the admin plugin obtained by other plugins is our admin plugin
            when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)

            # prepare a few players
            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 tearDown(self):
        self.console.working = False
#        sys.stdout.write("\tactive threads count : %s " % threading.activeCount())
#        sys.stderr.write("%s\n" % threading.enumerate())

    def init_default_cvar(self):
        when(self.console).getCvar('timelimit').thenReturn(Cvar('timelimit', value=20))
        when(self.console).getCvar('g_maxGameClients').thenReturn(Cvar('g_maxGameClients', value=16))
        when(self.console).getCvar('sv_maxclients').thenReturn(Cvar('sv_maxclients', value=16))
        when(self.console).getCvar('sv_privateClients').thenReturn(Cvar('sv_privateClients', value=0))
        when(self.console).getCvar('g_allowvote').thenReturn(Cvar('g_allowvote', value=0))
        when(self.console).getCvar('g_gear').thenReturn(Cvar('g_gear', value=''))
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:60,代码来源:__init__.py

示例15: test_functional

# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import onStartup [as 别名]
class test_functional(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        from b3.fake import FakeConsole
        RavagedParser.__bases__ = (FakeConsole,)
        # Now parser inheritance hierarchy is :
        # RavagedParser -> FakeConsole -> Parser


    def setUp(self):
        self.status_response = None # defaults to STATUS_RESPONSE module attribute
        self.conf = XmlConfigParser()
        self.conf.loadFromString("""<configuration></configuration>""")
        self.parser = RavagedParser(self.conf)
        self.parser.output = Mock()
        self.parser.output.write = Mock()

        ADMIN_CONFIG = XmlConfigParser()
        ADMIN_CONFIG.load(ADMIN_CONFIG_FILE)
        self.adminPlugin = AdminPlugin(self.parser, ADMIN_CONFIG)
        when(self.parser).getPlugin("admin").thenReturn(self.adminPlugin)
        self.adminPlugin.onLoadConfig()
        self.adminPlugin.onStartup()

        self.parser.startup()

    def tearDown(self):
        if hasattr(self, "parser"):
            del self.parser.clients
            self.parser.working = False



    def test_map(self):
        # GIVEN
        when(self.parser.output).write("getmaplist false").thenReturn(u"""0 CTR_Bridge
1 CTR_Canyon
2 CTR_Derelict
3 CTR_IceBreaker
4 CTR_Liberty
5 CTR_Rooftop
6 Thrust_Bridge
7 Thrust_Canyon
8 Thrust_Chasm
9 Thrust_IceBreaker
10 Thrust_Liberty
11 Thrust_Oilrig
12 Thrust_Rooftop
""".encode('UTF-8'))
        admin = FakeClient(console=self.parser, name="admin", guid="guid_admin", groupBits=128)
        admin.connects("guid_admin")
        # WHEN
        with patch.object(self.parser.output, 'write', wraps=self.parser.output.write) as write_mock:
            admin.says("!map chasm")
        # THEN
        write_mock.assert_has_calls([call("addmap Thrust_Chasm 1"), call("nextmap")])
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:59,代码来源:test_ravaged.py


注:本文中的b3.plugins.admin.AdminPlugin.onStartup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。