本文整理汇总了Python中b3.plugins.admin.AdminPlugin.cmd_maprotate方法的典型用法代码示例。如果您正苦于以下问题:Python AdminPlugin.cmd_maprotate方法的具体用法?Python AdminPlugin.cmd_maprotate怎么用?Python AdminPlugin.cmd_maprotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b3.plugins.admin.AdminPlugin
的用法示例。
在下文中一共展示了AdminPlugin.cmd_maprotate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Test_misc_cmd
# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import cmd_maprotate [as 别名]
class Test_misc_cmd(B3TestCase):
def setUp(self):
B3TestCase.setUp(self)
self.conf = XmlConfigParser()
self.conf.setXml("""
<configuration plugin="admin">
</configuration>
""")
self.p = AdminPlugin(b3.console, self.conf)
def test_die(self):
self.p.cmd_die(None, None, Mock())
assert b3.console.die.called
def test_restart(self):
self.p.cmd_restart(None, None, Mock())
assert b3.console.restart.called
def test_reconfig(self):
self.p.cmd_reconfig(None, None, Mock())
assert b3.console.reloadConfigs.called
def test_map(self):
mock_client = Mock(spec=Client, name="client")
# no data
self.p.cmd_map(data=None, client=mock_client, cmd=Mock(spec=Command))
mock_client.message.assert_called_once_with('^7You must supply a map to change to.')
assert not b3.console.changeMap.called
# correct data
mock_client.reset_mock()
b3.console.reset_mock()
b3.console.changeMap = Mock(return_value='foo')
self.p.cmd_map(data='bar', client=mock_client, cmd=Mock(spec=Command))
b3.console.changeMap.assert_called_once_with('bar')
assert not mock_client.message.called
# incorrect data
mock_client.reset_mock()
b3.console.reset_mock()
b3.console.changeMap = Mock(return_value=['foo1', 'foo2', 'foo3'])
self.p.cmd_map(data='bar', client=mock_client, cmd=Mock(spec=Command))
b3.console.changeMap.assert_called_once_with('bar')
assert mock_client.message.called
def test_maprotate(self):
self.p.cmd_maprotate(None, None, Mock(spec=Command))
assert b3.console.rotateMap.called
def test_b3(self):
self.p.config = Mock(name="config")
self.p.config.getint = Mock(return_value=10)
mock_client = Mock(spec=Client, name="client")
mock_command = Mock(spec=Command, name='cmd')
mock_client.maxLevel = 0
self.p.cmd_b3(data='', client=mock_client, cmd=mock_command)
assert mock_command.sayLoudOrPM.called
mock_client.maxLevel = 20
mock_client.reset_mock()
b3.console.reset_mock()
self.p.cmd_b3(data='', client=mock_client, cmd=mock_command)
assert mock_command.sayLoudOrPM.called
for param in ('poke', 'expose', 'stare', 'stab', 'triangulate', 'bite', 'fuck', 'slap', 'fight', 'feed',
'throw', 'furniture', 'indeed', 'flog', 'sexor', 'hate', 'smoke', 'maul', 'procreate',
'shoot'):
mock_client.reset_mock()
b3.console.reset_mock()
self.p.cmd_b3(data=param, client=mock_client, cmd=mock_command)
if not b3.console.say.called:
self.fail("b3.console.say was not called for %r" % param)
def test_enable(self):
mock_client = Mock(spec=Client, name="client")
mock_client.maxLevel = 0
mock_command = Mock(spec=Command, name='cmd')
self.p.cmd_enable(data='', client=mock_client, cmd=mock_command)
mock_client.message.assert_called_once_with('^7You must supply a plugin name to enable.')
mock_client.reset_mock()
self.p.cmd_enable(data='admin', client=mock_client, cmd=mock_command)
mock_client.message.assert_called_once_with('^7You cannot disable/enable the admin plugin.')
mock_client.reset_mock()
self.p.console.getPlugin = Mock(return_value=None)
self.p.cmd_enable(data='foo', client=mock_client, cmd=mock_command)
mock_client.message.assert_called_once_with('^7No plugin named foo loaded.')
mock_client.reset_mock()
mock_pluginA = Mock(spec=Plugin)
mock_pluginA.isEnabled = Mock(return_value=True)
self.p.console.getPlugin = Mock(return_value=mock_pluginA)
#.........这里部分代码省略.........