def test_plugin_view(self): """Should load plugin when module exists""" plugins = loader.import_plugins() self.assertEqual(len(plugins), 1) inject = getattr(plugins['monitoring'], 'inject') self.assertFalse(getattr(inject, '__is_view__', False)) links = getattr(plugins['monitoring'], 'links') self.assertTrue(getattr(links, '__is_view__'))
def test_import_plugin(self): """Should load plugin when module exists""" self.assertEqual(len(loader.import_plugins()), 1)
"""Plugins package""" from kitchen.backends.plugins.loader import import_plugins def is_view(plugin_type): """Decorator to mark a plugin method as being a view. Views can be called via the '/plugins/' interface of kitchen and should either return None or a proper Django HTTPResponse object """ if callable(plugin_type): plugin_type.__is_view__ = True plugin_type.__p_type__ = 'list' return plugin_type else: def inner(func): func.__is_view__ = True func.__p_type__ = plugin_type return func return inner plugins = import_plugins()
def test_import_plugin_not_found(self): """Should not load plugin when module doesn't exist""" self.assertEqual(len(loader.import_plugins()), 0)
"""Plugins package""" from kitchen.settings import ENABLE_PLUGINS from kitchen.backends.plugins.loader import import_plugins def is_view(plugin_type): """Decorator to mark a plugin method as being a view. Views can be called via the '/plugins/' interface of kitchen and should either return None or a proper Django HTTPResponse object """ if callable(plugin_type): plugin_type.__is_view__ = True plugin_type.__p_type__ = 'list' return plugin_type else: def inner(func): func.__is_view__ = True func.__p_type__ = plugin_type return func return inner plugins = import_plugins(ENABLE_PLUGINS)