本文整理汇总了Python中b3.config.XmlConfigParser类的典型用法代码示例。如果您正苦于以下问题:Python XmlConfigParser类的具体用法?Python XmlConfigParser怎么用?Python XmlConfigParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XmlConfigParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: Test_cmd_serverreboot
class Test_cmd_serverreboot(Bf3TestCase):
def setUp(self):
super(Test_cmd_serverreboot, self).setUp()
self.conf = XmlConfigParser()
self.conf.loadFromString("""
<configuration plugin="poweradminbf3">
<settings name="commands">
<set name="serverreboot">100</set>
</settings>
</configuration>
""")
self.p = Poweradminbf3Plugin(self.console, self.conf)
self.p.onLoadConfig()
self.p.onStartup()
def test_nominal(self, sleep_mock):
self.console.write.expect(('admin.shutDown',))
self.superadmin.connects("god")
self.superadmin.says("!serverreboot")
self.console.write.verify_expected_calls()
def test_frostbite_error(self, sleep_mock):
self.console.write.expect(('admin.shutDown',)).thenRaise(CommandFailedError(['fOO']))
self.superadmin.connects("god")
self.superadmin.message_history = []
self.superadmin.says("!serverreboot")
self.console.write.verify_expected_calls()
self.assertEqual(['Error: fOO'], self.superadmin.message_history)
开发者ID:82ndab-Bravo17,项目名称:b3-plugin-poweradminbf3,代码行数:29,代码来源:test_cmd_serverreboot.py
示例3: B3TestCase
class B3TestCase(unittest.TestCase):
def setUp(self):
testcase_lock.acquire()
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)
self.console.screen = Mock()
self.console.time = time.time
self.console.upTime = Mock(return_value=3)
self.console.cron.stop()
def myError(msg, *args, **kwargs):
print(("ERROR: %s" % msg) % args)
self.console.error = myError
def tearDown(self):
flush_console_streams()
testcase_lock.release()
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:26,代码来源:__init__.py
示例4: 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
示例5: test_others
class test_others(Arma2TestCase):
def setUp(self):
self.conf = XmlConfigParser()
self.conf.loadFromString("""<configuration></configuration>""")
self.parser = Arma2Parser(self.conf)
self.parser.output = Mock()
self.parser.startup()
self.player = self.parser.clients.newClient(cid="4", guid="theGuid", name="theName", ip="11.22.33.44")
def test_getBanlist(self):
# GIVEN
self.maxDiff = 1024
when(self.parser.output).write("bans").thenReturn("""\
GUID Bans:
[#] [GUID] [Minutes left] [Reason]
----------------------------------------
0 b57c222222a76f458893641000000005 perm Script Detection: Gerk
1 8ac61111111cd2ff4235140000000026 perm Script Detection: setVehicleInit DoThis;""")
# WHEN
rv = self.parser.getBanlist()
# THEN
self.assertDictEqual({
'b57c222222a76f458893641000000005': {'ban_index': '0', 'guid': 'b57c222222a76f458893641000000005', 'reason': 'Script Detection: Gerk', 'min_left': 'perm'},
'8ac61111111cd2ff4235140000000026': {'ban_index': '1', 'guid': '8ac61111111cd2ff4235140000000026', 'reason': 'Script Detection: setVehicleInit DoThis;', 'min_left': 'perm'},
}, rv)
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:27,代码来源:test_arma2.py
示例6: CensorurtTestCase
class CensorurtTestCase(B3TestCase):
"""
Ease testcases that need an working B3 console and need to control the censorurt plugin config
"""
def setUp(self):
# Timer needs to be patched or the Censor plugin would schedule a 2nd check one minute after
# penalizing a player.
self.timer_patcher = patch('threading.Timer')
self.timer_patcher.start()
self.log = logging.getLogger('output')
self.log.propagate = False
B3TestCase.setUp(self)
self.console.startup()
self.log.propagate = True
self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="zaerezarezar", groupBits=1, team=b3.TEAM_UNKNOWN)
self.conf = XmlConfigParser()
self.p = CensorurtPlugin(self.console, self.conf)
def tearDown(self):
B3TestCase.tearDown(self)
self.timer_patcher.stop()
def init_plugin(self, config_content):
self.conf.setXml(config_content)
self.log.setLevel(logging.DEBUG)
self.log.info("============================= Censor plugin: loading config ============================")
self.p.onLoadConfig()
self.log.info("============================= Censor plugin: starting =================================")
self.p.onStartup()
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:33,代码来源:__init__.py
示例7: setUp
def setUp(self):
BF3TestCase.setUp(self)
self.conf = XmlConfigParser()
self.conf.loadFromString("""
<configuration>
</configuration>
""")
self.console = Bf3Parser(self.conf)
from b3 import __file__ as b3_module__file__
admin_config_file = os.path.normpath(os.path.join(os.path.dirname(b3_module__file__), "conf/plugin_admin.xml"))
admin_config = XmlConfigParser()
admin_config.load(admin_config_file)
self.adminPlugin = AdminPlugin(self.console, admin_config)
self.adminPlugin.onLoadConfig()
self.adminPlugin.onStartup()
when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)
# monkeypatch the admin plugin
self.console.patch_b3_admin_plugin()
self.changeMap_patcher = patch.object(self.console, "changeMap")
self.changeMap_mock = self.changeMap_patcher.start()
self.player = FakeClient(self.console, name="Player1", guid="Player1GUID", groupBits=128)
self.player.connects("p1")
# GIVEN
self.console.game.gameType = 'ConquestLarge0'
when(self.console).write(('mapList.list', 0)).thenReturn(['4', '3', 'MP_001', 'RushLarge0', '1', 'MP_003',
'ConquestSmall0', '2', 'XP5_001', 'ConquestSmall0',
'2', 'MP_007', 'SquadDeathMatch0', '3'])
when(self.console).write(('mapList.getMapIndices',)).thenReturn(['0', '0'])
开发者ID:Classixz,项目名称:big-brother-bot,代码行数:33,代码来源:test_bf3.py
示例8: Test_bf3_events
class Test_bf3_events(BF3TestCase):
def setUp(self):
self.conf = XmlConfigParser()
self.conf.loadFromString("""
<configuration>
</configuration>
""")
self.parser = Bf3Parser(self.conf)
self.parser.startup()
def test_cmd_rotateMap_generates_EVT_GAME_ROUND_END(self):
# prepare fake BF3 server responses
def fake_write(data):
if data == ('mapList.getMapIndices', ):
return [0, 1]
else:
return []
self.parser.write = Mock(side_effect=fake_write)
self.parser.getFullMapRotationList = Mock(return_value=MapListBlock(['4', '3', 'MP_007', 'RushLarge0', '4', 'MP_011', 'RushLarge0', '4', 'MP_012',
'SquadRush0', '4', 'MP_013', 'SquadRush0', '4']))
# mock parser queueEvent method so we can make assertions on it later on
self.parser.queueEvent = Mock(name="queueEvent method")
self.parser.rotateMap()
self.assertEqual(1, self.parser.queueEvent.call_count)
self.assertEqual(self.parser.getEventID("EVT_GAME_ROUND_END"), self.parser.queueEvent.call_args[0][0].type)
self.assertIsNone(self.parser.queueEvent.call_args[0][0].data)
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:29,代码来源:test_bf3.py
示例9: AdminTestCase
class AdminTestCase(unittest.TestCase):
"""
Test case that is suitable for testing EtPro parser specific features with the B3 admin plugin available
"""
@classmethod
def setUpClass(cls):
from b3.fake import FakeConsole
AbstractParser.__bases__ = (FakeConsole,)
# Now parser inheritance hierarchy is :
# EtproParser -> AbstractParser -> 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 = EtproParser(self.conf)
self.parser.output = Mock()
self.parser.output.write = Mock(wraps=sys.stdout.write)
adminPlugin_conf = CfgConfigParser()
adminPlugin_conf.load(ADMIN_CONFIG_FILE)
adminPlugin = AdminPlugin(self.parser, adminPlugin_conf)
adminPlugin.onLoadConfig()
adminPlugin.onStartup()
when(self.parser).getPlugin('admin').thenReturn(adminPlugin)
when(self.parser).getCvar('b_privatemessages').thenReturn(Cvar('b_privatemessages', value='1'))
self.parser.startup()
def tearDown(self):
if hasattr(self, "parser"):
del self.parser.clients
self.parser.working = False
开发者ID:BigBrotherBot,项目名称:big-brother-bot,代码行数:32,代码来源:test_etpro.py
示例10: Test_getPlayerPings
class Test_getPlayerPings(BF3TestCase):
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")
def test_no_player(self):
# WHEN
actual_result = self.parser.getPlayerPings()
# THEN
self.assertDictEqual({}, actual_result)
def test_one_player(self):
# GIVEN
self.p1.connects("Player1")
when(self.parser).write(('player.ping', self.p1.cid)).thenReturn(['140'])
# WHEN
actual_result = self.parser.getPlayerPings()
# THEN
self.assertDictEqual({self.p1.cid: 140}, actual_result)
def test_two_player(self):
# GIVEN
self.p1.connects("Player1")
self.p2.connects("Player2")
when(self.parser).write(('player.ping', self.p1.cid)).thenReturn(['140'])
when(self.parser).write(('player.ping', self.p2.cid)).thenReturn(['450'])
# WHEN
actual_result = self.parser.getPlayerPings()
# THEN
self.assertDictEqual({self.p1.cid: 140, self.p2.cid: 450}, actual_result)
def test_bad_data(self):
# GIVEN
self.p1.connects("Player1")
self.p2.connects("Player2")
when(self.parser).write(('player.ping', self.p1.cid)).thenReturn(['140'])
when(self.parser).write(('player.ping', self.p2.cid)).thenReturn(['f00'])
# WHEN
actual_result = self.parser.getPlayerPings()
# THEN
self.assertDictEqual({self.p1.cid: 140}, actual_result)
def test_exception(self):
# GIVEN
self.p1.connects("Player1")
self.p2.connects("Player2")
when(self.parser).write(('player.ping', self.p1.cid)).thenReturn(['140'])
when(self.parser).write(('player.ping', self.p2.cid)).thenRaise(Exception)
# WHEN
actual_result = self.parser.getPlayerPings()
# THEN
self.assertDictEqual({self.p1.cid: 140}, actual_result)
开发者ID:Classixz,项目名称:big-brother-bot,代码行数:60,代码来源:test_bf3.py
示例11: 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
示例12: Test_cmd_yell
class Test_cmd_yell(Bf3TestCase):
def setUp(self):
Bf3TestCase.setUp(self)
self.conf = XmlConfigParser()
self.conf.loadFromString("""
<configuration plugin="poweradminbf3">
<settings name="commands">
<set name="yell">20</set>
</settings>
<settings name="preferences">
<set name="yell_duration">2</set>
</settings>
</configuration>
""")
self.p = Poweradminbf3Plugin(self.console, self.conf)
self.p.onLoadConfig()
self.p.onStartup()
def test_no_argument(self):
self.moderator.connects("moderator")
self.moderator.message_history = []
self.moderator.says("!yell")
self.assertEqual(1, len(self.moderator.message_history))
self.assertEqual('missing parameter, try !help yell', self.moderator.message_history[0])
def test_nominal(self):
self.moderator.connects("moderator")
self.moderator.says("!yell changing map soon !")
self.console.write.assert_called_once_with(('admin.yell', 'changing map soon !', '2'))
开发者ID:82ndab-Bravo17,项目名称:b3-plugin-poweradminbf3,代码行数:31,代码来源:test_cmd_yell.py
示例13: EtTestCase
class EtTestCase(unittest.TestCase):
"""
Test case that is suitable for testing et parser specific features
"""
@classmethod
def setUpClass(cls):
from b3.parsers.q3a.abstractParser import AbstractParser
from b3.fake import FakeConsole
AbstractParser.__bases__ = (FakeConsole,)
# Now parser inheritance hierarchy is :
# EtParser -> AbstractParser -> FakeConsole -> Parser
logging.getLogger('output').setLevel(logging.ERROR)
def setUp(self):
self.parser_conf = XmlConfigParser()
self.parser_conf.loadFromString("""<configuration>
<settings name="server">
<set name="game_log"/>
</settings>
</configuration>""")
self.console = EtParser(self.parser_conf)
self.console.write = Mock()
self.console.PunkBuster = None # no Punkbuster support in that game
def tearDown(self):
if hasattr(self, "parser"):
del self.parser.clients
self.parser.working = False
开发者ID:BigBrotherBot,项目名称:big-brother-bot,代码行数:31,代码来源:test_et.py
示例14: 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
示例15: test_nominal
def test_nominal(self):
conf = XmlConfigParser()
conf.setXml("""
<configuration plugin="teamspeakbf">
<settings name="teamspeakServer">
<set name="host">foo_host</set>
<set name="queryport">foo_queryport</set>
<set name="id">1</set>
<set name="login">foo_login</set>
<set name="password">foo_password</set>
</settings>
<settings name="teamspeakChannels">
<set name="B3">channel name</set>
<set name="team1">Team 1 name</set>
<set name="team2">Team 2 name</set>
<set name="DefaultTarget">team</set>
</settings>
</configuration>
""")
p = TeamspeakbfPlugin(fakeConsole, conf)
p.readConfig()
self.assertEqual('channel name', p.TS3ChannelB3)
self.assertEqual('Team 1 name', p.TS3ChannelTeam1)
self.assertEqual('Team 2 name', p.TS3ChannelTeam2)
self.assertEqual('team', p.autoswitchDefaultTarget)
开发者ID:82ndab-Bravo17,项目名称:b3-plugin-teamspeakbf,代码行数:25,代码来源:test_config.py
示例16: Iourt41TestCase
class Iourt41TestCase(unittest.TestCase):
"""
Test case that is suitable for testing iourt41 parser specific features
"""
@classmethod
def setUpClass(cls):
from b3.parsers.q3a.abstractParser import AbstractParser
from b3.fake import FakeConsole
AbstractParser.__bases__ = (FakeConsole,)
# Now parser inheritance hierarchy is :
# Iourt41Parser -> AbstractParser -> FakeConsole -> Parser
logging.getLogger('output').setLevel(logging.ERROR)
def setUp(self):
self.parser_conf = XmlConfigParser()
self.parser_conf.loadFromString("""
<configuration>
</configuration>
""")
self.console = Iourt41Parser(self.parser_conf)
self.console.PunkBuster = None # no Punkbuster support in that game
self.output_mock = mock()
# simulate game server actions
def write(*args, **kwargs):
pretty_args = map(repr, args) + ["%s=%s" % (k, v) for k, v in kwargs.iteritems()]
log.info("write(%s)" % ', '.join(pretty_args))
return self.output_mock.write(*args, **kwargs)
self.console.write = write
开发者ID:ozon,项目名称:big-brother-bot,代码行数:31,代码来源:test_iourt41.py
示例17: testAdmins
def testAdmins():
conf = XmlConfigParser()
conf.setXml("""
<configuration plugin="adv">
<settings name="settings">
<set name="rate">1s</set>
</settings>
<ads>
<ad>^2Do you like B3? Consider donating to the project at www.BigBrotherBot.net</ad>
<ad>@admins</ad>
</ads>
</configuration>
""")
p = AdvPlugin(fakeConsole, conf)
p.onStartup()
p.adv()
print "-----------------------------"
time.sleep(4)
joe.connects(1)
time.sleep(4)
moderator.connects(2)
time.sleep(4)
superadmin.connects(3)
time.sleep(60)
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:26,代码来源:adv.py
示例18: 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
示例19: Test_getGamemodeSoundingLike
class Test_getGamemodeSoundingLike(MohwTestCase):
"""
make sure that getGamemodeSoundingLike returns expected results
"""
def setUp(self):
MohwTestCase.setUp(self)
self.conf = XmlConfigParser()
self.conf.loadFromString("""
<configuration>
</configuration>
""")
self.parser = MohwParser(self.conf)
def test_CombatMission(self):
self.assertEqual('CombatMission', self.parser.getGamemodeSoundingLike('MP_03', 'CombatMission'))
self.assertEqual('CombatMission', self.parser.getGamemodeSoundingLike('MP_03', 'Combat Mission'))
self.assertEqual('CombatMission', self.parser.getGamemodeSoundingLike('MP_03', 'Combt Mission'))
self.assertEqual('CombatMission', self.parser.getGamemodeSoundingLike('MP_03', 'Mission'))
self.assertEqual('CombatMission', self.parser.getGamemodeSoundingLike('MP_03', 'combat'))
self.assertEqual('CombatMission', self.parser.getGamemodeSoundingLike('MP_03', 'cm'))
def test_Sport(self):
self.assertEqual('Sport', self.parser.getGamemodeSoundingLike('MP_03', 'Sport'))
self.assertEqual('Sport', self.parser.getGamemodeSoundingLike('MP_03', 'Home Run'))
self.assertEqual('Sport', self.parser.getGamemodeSoundingLike('MP_03', 'Home'))
self.assertEqual('Sport', self.parser.getGamemodeSoundingLike('MP_03', 'run'))
self.assertEqual('Sport', self.parser.getGamemodeSoundingLike('MP_03', 'homerun'))
self.assertEqual('Sport', self.parser.getGamemodeSoundingLike('MP_03', 'hr'))
def test_SectorControl(self):
self.assertEqual('SectorControl', self.parser.getGamemodeSoundingLike('MP_03', 'SectorControl'))
self.assertEqual('SectorControl', self.parser.getGamemodeSoundingLike('MP_03', 'Sector Control'))
self.assertEqual('SectorControl', self.parser.getGamemodeSoundingLike('MP_03', 'Sector'))
self.assertEqual('SectorControl', self.parser.getGamemodeSoundingLike('MP_03', 'control'))
self.assertEqual('SectorControl', self.parser.getGamemodeSoundingLike('MP_03', 'sc'))
def test_TeamDeathMatch(self):
self.assertEqual('TeamDeathMatch', self.parser.getGamemodeSoundingLike('MP_03', 'TeamDeathMatch'))
self.assertEqual('TeamDeathMatch', self.parser.getGamemodeSoundingLike('MP_03', 'Team DeathMatch'))
self.assertEqual('TeamDeathMatch', self.parser.getGamemodeSoundingLike('MP_03', 'Team Death Match'))
self.assertEqual('TeamDeathMatch', self.parser.getGamemodeSoundingLike('MP_03', 'Death Match'))
self.assertEqual('TeamDeathMatch', self.parser.getGamemodeSoundingLike('MP_03', 'team'))
self.assertEqual('TeamDeathMatch', self.parser.getGamemodeSoundingLike('MP_03', 'death'))
self.assertEqual('TeamDeathMatch', self.parser.getGamemodeSoundingLike('MP_03', 'Match'))
self.assertEqual('TeamDeathMatch', self.parser.getGamemodeSoundingLike('MP_03', 'tdm'))
def test_BombSquad(self):
self.assertEqual('BombSquad', self.parser.getGamemodeSoundingLike('MP_03', 'BombSquad'))
self.assertEqual('BombSquad', self.parser.getGamemodeSoundingLike('MP_03', 'Hot Spot'))
self.assertEqual('BombSquad', self.parser.getGamemodeSoundingLike('MP_03', 'Hotspot'))
self.assertEqual('BombSquad', self.parser.getGamemodeSoundingLike('MP_03', 'hot'))
self.assertEqual('BombSquad', self.parser.getGamemodeSoundingLike('MP_03', 'spot'))
self.assertEqual('BombSquad', self.parser.getGamemodeSoundingLike('MP_03', 'Bomb'))
self.assertEqual('BombSquad', self.parser.getGamemodeSoundingLike('MP_03', 'hs'))
def test_suggestions(self):
# unrecognizable input, falling back on available gamemodes for current map
self.assertEqual(['Team Death Match', 'Combat Mission', 'Home Run'],
self.parser.getGamemodeSoundingLike('MP_12', ''))
开发者ID:BigBrotherBot,项目名称:big-brother-bot,代码行数:60,代码来源:test_mohw.py
示例20: Test_Client_player_type
class Test_Client_player_type(BFHTestCase):
def setUp(self):
BFHTestCase.setUp(self)
self.conf = XmlConfigParser()
self.conf.loadFromString("""
<configuration>
</configuration>
""")
self.parser = BfhParser(self.conf)
self.foobar = self.parser.clients.newClient(cid='Foobar', name='Foobar', guid="FoobarGuid")
def test_player_type_player(self):
# GIVEN
when(self.parser).write(('admin.listPlayers', 'player', 'Foobar')).thenReturn(
['10', 'name', 'guid', 'teamId', 'squadId', 'kills', 'deaths', 'score', 'rank', 'ping', 'type', '1',
'Foobar', 'xxxxy', '1', '0', '0', '0', '0', '71', '65535', '0'])
# THEN
self.assertEqual(BFH_PLAYER, self.foobar.player_type)
def test_player_type_spectator(self):
# GIVEN
when(self.parser).write(('admin.listPlayers', 'player', 'Foobar')).thenReturn(
['10', 'name', 'guid', 'teamId', 'squadId', 'kills', 'deaths', 'score', 'rank', 'ping', 'type', '1',
'Foobar', 'xxxxy', '0', '0', '0', '0', '0', '71', '65535', '1'])
# THEN
self.assertEqual(BFH_SPECTATOR, self.foobar.player_type)
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:26,代码来源:test_bfh.py
注:本文中的b3.config.XmlConfigParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论