本文整理汇总了Python中system.command_manager.CommandManager.unregister_commands_for_owner方法的典型用法代码示例。如果您正苦于以下问题:Python CommandManager.unregister_commands_for_owner方法的具体用法?Python CommandManager.unregister_commands_for_owner怎么用?Python CommandManager.unregister_commands_for_owner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类system.command_manager.CommandManager
的用法示例。
在下文中一共展示了CommandManager.unregister_commands_for_owner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from system.command_manager import CommandManager [as 别名]
# 或者: from system.command_manager.CommandManager import unregister_commands_for_owner [as 别名]
class test_commands:
def __init__(self):
self.manager = CommandManager()
self.manager.logger.setLevel(logging.CRITICAL) # Shut up, logger
self.factory_manager = Mock(name="factory_manager")
self.plugin = Mock(name="plugin")
@nosetools.nottest
def teardown(self):
# Clean up
self.manager.commands = {}
self.manager.aliases = {}
self.manager.auth_handler = None
self.manager.perm_handler = None
self.plugin.reset_mock()
self.plugin.handler.reset_mock()
self.factory_manager.reset_mock()
@nose.with_setup(teardown=teardown)
def test_singleton(self):
"""CMNDS | Test Singleton metaclass"""
nosetools.assert_true(self.manager is CommandManager())
@nose.with_setup(teardown=teardown)
def test_set_factory_manager(self):
"""CMNDS | Test setting factory manager"""
self.manager.set_factory_manager(self.factory_manager)
nosetools.assert_true(self.factory_manager)
@nose.with_setup(teardown=teardown)
def test_add_command(self):
"""CMNDS | Test adding commands"""
r = self.manager.register_command("test", self.plugin.handler,
self.plugin, "test.test",
["test2"], True)
nosetools.assert_true(r)
nosetools.assert_true("test" in self.manager.commands)
command = self.manager.commands.get("test", None)
if command:
nosetools.assert_true("f" in command)
nosetools.assert_true(command.get("f") is self.plugin.handler)
nosetools.assert_true("permission" in command)
nosetools.assert_true(command.get("permission") == "test.test")
nosetools.assert_true("owner" in command)
nosetools.assert_true(command.get("owner") is self.plugin)
nosetools.assert_true("default" in command)
nosetools.assert_true(command.get("default"))
nosetools.assert_true("test2" in self.manager.aliases)
alias = self.manager.aliases.get("test2", None)
if alias:
nosetools.assert_true(alias == "test")
r = self.manager.register_command("test", self.plugin.handler,
self.plugin, "test.test",
["test2"], True)
nosetools.assert_false(r)
@nose.with_setup(teardown=teardown)
def test_unregister_commands(self):
"""CMNDS | Test unregistering commands"""
self.manager.register_command("test1", self.plugin.handler,
self.plugin, aliases=["test11"])
self.manager.register_command("test2", self.plugin.handler,
self.plugin, aliases=["test22"])
self.manager.register_command("test3", self.plugin.handler,
self.plugin, aliases=["test33"])
nosetools.assert_equals(len(self.manager.commands), 3)
nosetools.assert_equals(len(self.manager.aliases), 3)
self.manager.unregister_commands_for_owner(self.plugin)
nosetools.assert_equals(len(self.manager.commands), 0)
nosetools.assert_equals(len(self.manager.aliases), 0)
@nose.with_setup(teardown=teardown)
def test_run_commands_defaults(self):
"""CMNDS | Test running commands directly | Defaults"""
self.manager.register_command("test4", self.plugin.handler,
self.plugin, aliases=["test5"],
default=True)
caller = Mock(name="caller")
source = Mock(name="source")
protocol = Mock(name="protocol")
#.........这里部分代码省略.........