Ejemplo n.º 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()}
        with mock.patch("tacker.api.extensions.PluginAwareExtensionManager."
                        "check_if_plugin_extensions_loaded"):
            ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)
            ext_mgr.add_extension(
                ext_stubs.ExtensionExpectingPluginInterface(
                    "supported_extension"))

            self.assertNotIn("e1", ext_mgr.extensions)
Ejemplo n.º 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()}
        with mock.patch("tacker.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)