本文整理汇总了Python中b3.plugins.admin.AdminPlugin类的典型用法代码示例。如果您正苦于以下问题:Python AdminPlugin类的具体用法?Python AdminPlugin怎么用?Python AdminPlugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AdminPlugin类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: PluginmanagerTestCase
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,代码行数:32,代码来源:__init__.py
示例2: CustomcommandsTestCase
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,代码行数:29,代码来源:__init__.py
示例3: ProxyfilterTestCase
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,代码行数:26,代码来源:__init__.py
示例4: setUp
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,代码行数:33,代码来源:__init__.py
示例5: Welcome_functional_test
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,代码行数:30,代码来源:__init__.py
示例6: ChatloggerTestCase
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,代码行数:29,代码来源:__init__.py
示例7: Iourt41TestCase
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,代码行数:30,代码来源:__init__.py
示例8: DuelTestCase
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,代码行数:32,代码来源:__init__.py
示例9: Admin_functional_test
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,代码行数:25,代码来源:test_admin_functional.py
示例10: CalladminTestCase
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,代码行数:25,代码来源:__init__.py
示例11: PluginTestCase
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,代码行数:35,代码来源:__init__.py
示例12: Iourt41TestCase
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,代码行数:59,代码来源:__init__.py
示例13: MapcycleTestCase
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,代码行数:58,代码来源:__init__.py
示例14: Iourt41TestCase
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,代码行数:58,代码来源:__init__.py
示例15: test_functional
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,代码行数:57,代码来源:test_ravaged.py
示例16: Admin_TestCase
class Admin_TestCase(B3TestCase):
def setUp(self):
B3TestCase.setUp(self)
self.conf = XmlConfigParser()
self.conf.load(ADMIN_CONFIG_FILE)
self.p = AdminPlugin(self.console, self.conf)
self.p.onLoadConfig()
self.p.onStartup()
开发者ID:ozon,项目名称:big-brother-bot,代码行数:9,代码来源:test_admin.py
示例17: SpreeTestCase
class SpreeTestCase(unittest2.TestCase):
def setUp(self):
# create a FakeConsole parser
parser_ini_conf = CfgConfigParser()
parser_ini_conf.loadFromString(r'''''')
self.parser_main_conf = MainConfig(parser_ini_conf)
with logging_disabled():
from b3.fake import FakeConsole
self.console = FakeConsole(self.parser_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 = SpreePlugin(self.console, CfgConfigParser())
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)
def tearDown(self):
unstub()
def init(self, config_content=None):
"""
Initialize the plugin using the given configuration file content
"""
if not config_content:
config_content = dedent(r"""
[settings]
reset_spree: yes
[killingspree_messages]
5: %player% is on a killing spree (5 kills in a row) # %player% stopped the spree of %victim%
10: %player% is on fire! (10 kills in a row) # %player% iced %victim%
[loosingspree_messages]
12: Keep it up %player%, it will come eventually # You're back in business %player%
[commands]
spree: user
""")
self.p.config.loadFromString(config_content)
self.p.onLoadConfig()
self.p.onStartup()
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:55,代码来源:__init__.py
示例18: Bf3TestCase
class Bf3TestCase(unittest.TestCase):
"""
Test case that is suitable for testing BF3 parser specific features
"""
@classmethod
def setUpClass(cls):
# less logging
logging.getLogger('output').setLevel(logging.ERROR)
from b3.parsers.frostbite2.abstractParser import AbstractParser
from b3.fake import FakeConsole
AbstractParser.__bases__ = (FakeConsole,)
# Now parser inheritance hierarchy is :
# Bf3Parser -> AbstractParser -> FakeConsole -> Parser
# Update method says of FakeClient so it let the Bf3Parser fire the SAY event
def says(self, msg):
print "\n%s says \"%s\"" % (self.name, msg)
self.console.queueEvent(self.console.OnPlayerChat(action=None, data=(self.cid, msg, 'all')))
FakeClient.says = says
def setUp(self):
# create a BF3 parser
self.parser_conf = XmlConfigParser()
self.parser_conf.loadFromString(r"""<configuration/>""")
self.console = Bf3Parser(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()
#when(self.console).time().thenReturn(time.time())
# 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", 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
开发者ID:manishas,项目名称:b3-plugin-votemapbf3,代码行数:54,代码来源:__init__.py
示例19: UrtauthTestCase
class UrtauthTestCase(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)
when(self.console).getCvar('auth').thenReturn(Cvar('auth', value='1'))
when(self.console).getCvar('fs_basepath').thenReturn(Cvar('fs_basepath', value='/fake/basepath'))
when(self.console).getCvar('fs_homepath').thenReturn(Cvar('fs_homepath', 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)
self.conf = CfgConfigParser()
self.conf.loadFromString(dedent(r"""
[settings]
maxlevel: reg
reason: ^7you need an ^1auth ^7account to play here
"""))
self.p = UrtauthPlugin(self.console, self.conf)
self.p.onLoadConfig()
self.p.onStartup()
def tearDown(self):
self.console.working = False
开发者ID:danielepantaleone,项目名称:b3-plugin-urtauth,代码行数:54,代码来源:__init__.py
示例20: Iourt41TestCase
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.ERROR)
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 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
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
# when starting the PoweradminurtPlugin expects the game server to provide a few cvar values
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))
# 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)
def tearDown(self):
self.console.working = False
开发者ID:danielepantaleone,项目名称:b3-plugin-headshotsurt,代码行数:54,代码来源:__init__.py
注:本文中的b3.plugins.admin.AdminPlugin类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论