本文整理匯總了Python中quantum.extensions.extensions.PluginAwareExtensionManager.add_extension方法的典型用法代碼示例。如果您正苦於以下問題:Python PluginAwareExtensionManager.add_extension方法的具體用法?Python PluginAwareExtensionManager.add_extension怎麽用?Python PluginAwareExtensionManager.add_extension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類quantum.extensions.extensions.PluginAwareExtensionManager
的用法示例。
在下文中一共展示了PluginAwareExtensionManager.add_extension方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_unsupported_extensions_are_not_loaded
# 需要導入模塊: from quantum.extensions.extensions import PluginAwareExtensionManager [as 別名]
# 或者: from quantum.extensions.extensions.PluginAwareExtensionManager import add_extension [as 別名]
def test_unsupported_extensions_are_not_loaded(self):
stub_plugin = StubPlugin(supported_extensions=["e1", "e3"])
ext_mgr = PluginAwareExtensionManager('', stub_plugin)
ext_mgr.add_extension(StubExtension("e1"))
ext_mgr.add_extension(StubExtension("e2"))
ext_mgr.add_extension(StubExtension("e3"))
self.assertTrue("e1" in ext_mgr.extensions)
self.assertFalse("e2" in ext_mgr.extensions)
self.assertTrue("e3" in ext_mgr.extensions)
示例2: test_extensions_expecting_quantum_plugin_interface_are_loaded
# 需要導入模塊: from quantum.extensions.extensions import PluginAwareExtensionManager [as 別名]
# 或者: from quantum.extensions.extensions.PluginAwareExtensionManager import add_extension [as 別名]
def test_extensions_expecting_quantum_plugin_interface_are_loaded(self):
class ExtensionForQuamtumPluginInterface(StubExtension):
"""
This Extension does not implement get_plugin_interface method.
This will work with any plugin implementing QuantumPluginBase
"""
pass
stub_plugin = StubPlugin(supported_extensions=["e1"])
ext_mgr = PluginAwareExtensionManager('', stub_plugin)
ext_mgr.add_extension(ExtensionForQuamtumPluginInterface("e1"))
self.assertTrue("e1" in ext_mgr.extensions)
示例3: test_extensions_are_not_loaded_for_plugins_unaware_of_extensions
# 需要導入模塊: from quantum.extensions.extensions import PluginAwareExtensionManager [as 別名]
# 或者: from quantum.extensions.extensions.PluginAwareExtensionManager import add_extension [as 別名]
def test_extensions_are_not_loaded_for_plugins_unaware_of_extensions(self):
class ExtensionUnawarePlugin(object):
"""
This plugin does not implement supports_extension method.
Extensions will not be loaded when this plugin is used.
"""
pass
ext_mgr = PluginAwareExtensionManager('', ExtensionUnawarePlugin())
ext_mgr.add_extension(StubExtension("e1"))
self.assertFalse("e1" in ext_mgr.extensions)
示例4: test_extensions_not_loaded_for_plugin_without_expected_interface
# 需要導入模塊: from quantum.extensions.extensions import PluginAwareExtensionManager [as 別名]
# 或者: from quantum.extensions.extensions.PluginAwareExtensionManager import add_extension [as 別名]
def test_extensions_not_loaded_for_plugin_without_expected_interface(self):
class PluginWithoutExpectedInterface(object):
"""
Plugin does not implement get_foo method as expected by extension
"""
supported_extension_aliases = ["supported_extension"]
ext_mgr = PluginAwareExtensionManager("", PluginWithoutExpectedInterface())
ext_mgr.add_extension(ExtensionExpectingPluginInterface("supported_extension"))
self.assertFalse("e1" in ext_mgr.extensions)
示例5: test_extensions_without_need_for__plugin_interface_are_loaded
# 需要導入模塊: from quantum.extensions.extensions import PluginAwareExtensionManager [as 別名]
# 或者: from quantum.extensions.extensions.PluginAwareExtensionManager import add_extension [as 別名]
def test_extensions_without_need_for__plugin_interface_are_loaded(self):
class ExtensionWithNoNeedForPluginInterface(StubExtension):
"""
This Extension does not need any plugin interface.
This will work with any plugin implementing QuantumPluginBase
"""
def get_plugin_interface(self):
return None
stub_plugin = StubPlugin(supported_extensions=["e1"])
ext_mgr = PluginAwareExtensionManager('', stub_plugin)
ext_mgr.add_extension(ExtensionWithNoNeedForPluginInterface("e1"))
self.assertTrue("e1" in ext_mgr.extensions)
示例6: test_extensions_are_loaded_for_plugin_with_expected_interface
# 需要導入模塊: from quantum.extensions.extensions import PluginAwareExtensionManager [as 別名]
# 或者: from quantum.extensions.extensions.PluginAwareExtensionManager import add_extension [as 別名]
def test_extensions_are_loaded_for_plugin_with_expected_interface(self):
class PluginWithExpectedInterface(object):
"""
This Plugin implements get_foo method as expected by extension
"""
supported_extension_aliases = ["supported_extension"]
def get_foo(self, bar=None):
pass
ext_mgr = PluginAwareExtensionManager("", PluginWithExpectedInterface())
ext_mgr.add_extension(ExtensionExpectingPluginInterface("supported_extension"))
self.assertTrue("supported_extension" in ext_mgr.extensions)