def test_handles_mapping_functions_across_plugins(entry_points_mck): """Verify we can use the PluginManager call functions on all plugins.""" entry_points_mck.return_value = { 'testing.entrypoints': [ importlib_metadata.EntryPoint('T100', '', None), importlib_metadata.EntryPoint('T200', '', None), ], } plugin_mgr = manager.PluginManager(namespace='testing.entrypoints') plugins = [plugin_mgr.plugins[name] for name in plugin_mgr.names] assert list(plugin_mgr.map(lambda x: x)) == plugins
def test_calls_entrypoints_creates_plugins_automaticaly(entry_points_mck): """Verify that we create Plugins on instantiation.""" entry_points_mck.return_value = { 'testing.entrypoints': [ importlib_metadata.EntryPoint('T100', '', None), importlib_metadata.EntryPoint('T200', '', None), ], } plugin_mgr = manager.PluginManager(namespace='testing.entrypoints') entry_points_mck.assert_called_once_with() assert 'T100' in plugin_mgr.plugins assert 'T200' in plugin_mgr.plugins assert isinstance(plugin_mgr.plugins['T100'], manager.Plugin) assert isinstance(plugin_mgr.plugins['T200'], manager.Plugin)
def test_calls_entrypoints_creates_plugins_automaticaly(entry_points_mck): """Verify that we create Plugins on instantiation.""" entry_points_mck.return_value = { "testing.entrypoints": [ importlib_metadata.EntryPoint("T100", "", "testing.entrypoints"), importlib_metadata.EntryPoint("T200", "", "testing.entrypoints"), ], } plugin_mgr = manager.PluginManager(namespace="testing.entrypoints") entry_points_mck.assert_called_once_with() assert "T100" in plugin_mgr.plugins assert "T200" in plugin_mgr.plugins assert isinstance(plugin_mgr.plugins["T100"], manager.Plugin) assert isinstance(plugin_mgr.plugins["T200"], manager.Plugin)
def _load_local_plugins(self, local_plugins): """Load local plugins from config. :param list local_plugins: Plugins from config (as "X = path.to:Plugin" strings). """ for plugin_str in local_plugins: name, _, entry_str = plugin_str.partition("=") name, entry_str = name.strip(), entry_str.strip() entry_point = importlib_metadata.EntryPoint(name, entry_str, None) self._load_plugin_from_entrypoint(entry_point, local=True)