Exemple #1
0
    def test_extensions_not_loaded_for_plugin_without_expected_interface(self):
        class PluginWithoutExpectedIface(object):
            """Does not implement get_foo method as expected by extension."""
            supported_extension_aliases = ["supported_extension"]

        plugin_info = {constants.CORE: PluginWithoutExpectedIface()}
        ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)
        ext_mgr.add_extension(
            ext_stubs.ExtensionExpectingPluginInterface("supported_extension"))

        self.assertNotIn("e1", ext_mgr.extensions)
Exemple #2
0
    def test_extensions_are_loaded_for_plugin_with_expected_interface(self):
        class PluginWithExpectedInterface(object):
            """Implements get_foo method as expected by extension."""
            supported_extension_aliases = ["supported_extension"]

            def get_foo(self, bar=None):
                pass

        plugin_info = {constants.CORE: PluginWithExpectedInterface()}
        ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)
        ext_mgr.add_extension(
            ext_stubs.ExtensionExpectingPluginInterface("supported_extension"))

        self.assertIn("supported_extension", ext_mgr.extensions)
Exemple #3
0
    def test_extensions_are_loaded_for_plugin_with_expected_interface(self):
        class PluginWithExpectedInterface(service_base.ServicePluginBase):
            """Implements get_foo method as expected by extension."""
            supported_extension_aliases = ["supported_extension"]

            def get_foo(self, bar=None):
                pass

            def get_plugin_type(self):
                pass

            def get_plugin_description(self):
                pass

        plugin_info = {lib_const.CORE: PluginWithExpectedInterface()}
        with mock.patch("neutron.api.extensions.PluginAwareExtensionManager."
                        "check_if_plugin_extensions_loaded"):
            ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)
            ext_mgr.add_extension(
                ext_stubs.ExtensionExpectingPluginInterface(
                    "supported_extension"))

            self.assertIn("supported_extension", ext_mgr.extensions)