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)
    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)
    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)
Example #4
0
    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)
Example #5
0
    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)
Example #6
0
    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)
    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)
    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)
Example #9
0
    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)
    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)
Example #11
0
    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)
Example #12
0
    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)
Example #13
0
def setup_extensions_middleware(extension_manager=None):
    extension_manager = (extension_manager or PluginAwareExtensionManager(
        extensions_path, QuantumEchoPlugin()))
    options = {'config_file': test_conf_file}
    conf, app = config.load_paste_app('extensions_test_app', options, None)
    return ExtensionMiddleware(app, conf, ext_mgr=extension_manager)