本文整理汇总了Python中b3.plugins.admin.AdminPlugin.cmd_rebuild方法的典型用法代码示例。如果您正苦于以下问题:Python AdminPlugin.cmd_rebuild方法的具体用法?Python AdminPlugin.cmd_rebuild怎么用?Python AdminPlugin.cmd_rebuild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b3.plugins.admin.AdminPlugin
的用法示例。
在下文中一共展示了AdminPlugin.cmd_rebuild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Test_misc_cmd
# 需要导入模块: from b3.plugins.admin import AdminPlugin [as 别名]
# 或者: from b3.plugins.admin.AdminPlugin import cmd_rebuild [as 别名]
#.........这里部分代码省略.........
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)
self.p.cmd_enable(data='foo', client=mock_client, cmd=mock_command)
mock_client.message.assert_called_once_with('^7Plugin foo is already enabled.')
mock_client.reset_mock()
mock_pluginA = Mock(spec=Plugin)
mock_pluginA.__class__.__name__ = "MockPlugin"
mock_pluginA.isEnabled = Mock(return_value=False)
self.p.console.getPlugin = Mock(return_value=mock_pluginA)
self.p.cmd_enable(data='foo', client=mock_client, cmd=mock_command)
self.p.console.say.assert_called_once_with('^7MockPlugin is now ^2ON')
def test_disable(self):
mock_client = Mock(spec=Client, name="client")
mock_client.maxLevel = 0
mock_command = Mock(spec=Command, name='cmd')
self.p.cmd_disable(data='', client=mock_client, cmd=mock_command)
mock_client.message.assert_called_once_with('^7You must supply a plugin name to disable.')
mock_client.reset_mock()
self.p.cmd_disable(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_disable(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=False)
self.p.console.getPlugin = Mock(return_value=mock_pluginA)
self.p.cmd_disable(data='foo', client=mock_client, cmd=mock_command)
mock_client.message.assert_called_once_with('^7Plugin foo is already disable.')
mock_client.reset_mock()
mock_pluginA = Mock(spec=Plugin)
mock_pluginA.__class__.__name__ = "MockPlugin"
mock_pluginA.isEnabled = Mock(return_value=True)
self.p.console.getPlugin = Mock(return_value=mock_pluginA)
self.p.cmd_disable(data='foo', client=mock_client, cmd=mock_command)
self.p.console.say.assert_called_once_with('^7MockPlugin is now ^1OFF')
def test_rebuild(self):
mock_client = Mock(spec=Client, name="client")
mock_client.maxLevel = 0
mock_command = Mock(spec=Command, name='cmd')
assert not self.p.console.clients.sync.called
self.p.cmd_rebuild(data='', client=mock_client, cmd=mock_command)
assert self.p.console.clients.sync.called