Example #1
0
def test_local_plugins(entry_points_mck):
    """Verify PluginManager can load given local plugins."""
    entry_points_mck.return_value = {}
    plugin_mgr = manager.PluginManager(namespace='testing.entrypoints',
                                       local_plugins=['X = path.to:Plugin'])

    assert plugin_mgr.plugins['X'].entry_point.value == 'path.to:Plugin'
Example #2
0
def test_local_plugins(iter_entry_points):
    """Verify PluginManager can load given local plugins."""
    iter_entry_points.return_value = []
    plugin_mgr = manager.PluginManager(
        namespace='testing.pkg_resources',
        local_plugins=['X = path.to:Plugin']
    )

    assert plugin_mgr.plugins['X'].entry_point.module_name == 'path.to'
Example #3
0
def test_local_plugins(get_group_all):
    """Verify PluginManager can load given local plugins."""
    get_group_all.return_value = []
    plugin_mgr = manager.PluginManager(
        namespace='testing.entrypoints',
        local_plugins=['X = path.to:Plugin']
    )

    assert plugin_mgr.plugins['X'].entry_point.module_name == 'path.to'
Example #4
0
def test_handles_mapping_functions_across_plugins(iter_entry_points):
    """Verify we can use the PluginManager call functions on all plugins."""
    entry_point_mocks = [
        create_entry_point_mock('T100'),
        create_entry_point_mock('T200'),
    ]
    iter_entry_points.return_value = entry_point_mocks
    plugin_mgr = manager.PluginManager(namespace='testing.pkg_resources')
    plugins = [plugin_mgr.plugins[name] for name in plugin_mgr.names]

    assert list(plugin_mgr.map(lambda x: x)) == plugins
Example #5
0
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
Example #6
0
def test_calls_pkg_resources_creates_plugins_automaticaly(iter_entry_points):
    """Verify that we create Plugins on instantiation."""
    iter_entry_points.return_value = [
        create_entry_point_mock('T100'),
        create_entry_point_mock('T200'),
    ]
    plugin_mgr = manager.PluginManager(namespace='testing.pkg_resources')

    iter_entry_points.assert_called_once_with('testing.pkg_resources')
    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)
Example #7
0
def test_calls_entrypoints_creates_plugins_automaticaly(get_group_all):
    """Verify that we create Plugins on instantiation."""
    get_group_all.return_value = [
        create_entry_point_mock('T100'),
        create_entry_point_mock('T200'),
    ]
    plugin_mgr = manager.PluginManager(namespace='testing.entrypoints')

    get_group_all.assert_called_once_with('testing.entrypoints')
    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)
Example #8
0
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)
Example #9
0
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)
Example #10
0
def test_calls_entrypoints_on_instantiation(entry_points_mck):
    """Verify that we call entry_points() when we create a manager."""
    entry_points_mck.return_value = {}
    manager.PluginManager(namespace='testing.entrypoints')
    entry_points_mck.assert_called_once_with()
Example #11
0
def test_calls_pkg_resources_on_instantiation(iter_entry_points):
    """Verify that we call iter_entry_points when we create a manager."""
    iter_entry_points.return_value = []
    manager.PluginManager(namespace='testing.pkg_resources')

    iter_entry_points.assert_called_once_with('testing.pkg_resources')
Example #12
0
def test_calls_entrypoints_on_instantiation(get_group_all):
    """Verify that we call get_group_all when we create a manager."""
    get_group_all.return_value = []
    manager.PluginManager(namespace='testing.entrypoints')

    get_group_all.assert_called_once_with('testing.entrypoints')