Beispiel #1
0
def test_plugin_manager():
    plugin_dir = os.path.join(ROOT_DIR, "data", "mock_plugin")
    pm = PluginManager(plugin_dir)
    plugins = pm.available_plugins
    assert sorted(plugins) == sorted(['mock_plugin', 'broken_plugin'])
    module = pm.load_plugin('mock_plugin')
    assert module.init_plugin() == "mock plug-in initialized"
Beispiel #2
0
def test_add_active_plugin():
    plugin_dir = os.path.join(ROOT_DIR, "data", "mock_plugin")
    pm = PluginManager(plugin_dir, ["mock_plugin", ])
    pm.start_active_plugins()
Beispiel #3
0
def test_add_str_active_plugin():
    plugin_dir = os.path.join(ROOT_DIR, "data", "mock_plugin")
    pm = PluginManager(plugin_dir)
    pm.activate_plugin("mock_plugin")
    assert pm.active_plugins == ["mock_plugin"]
Beispiel #4
0
def test_add_list_active_plugin():
    plugin_dir = os.path.join(ROOT_DIR, "data", "mock_plugin")
    pm = PluginManager(plugin_dir)
    pm.activate_plugin(["mock_plugin", "broken_plugin"])
    print(pm.active_plugins)
    assert pm.active_plugins == ["mock_plugin", "broken_plugin"]
Beispiel #5
0
def test_plugins_list():
    plugin_dir = os.path.join(ROOT_DIR, "data", "mock_plugin")
    pm = PluginManager(plugin_dir, ["mock_plugin", ])
    assert pm.active_plugins == ["mock_plugin"]
Beispiel #6
0
def test_nonexisting_plugin_manager():
    plugin_dir = os.path.join(ROOT_DIR, "data", "mock_plugin")
    pm = PluginManager(plugin_dir)
    with pytest.raises(ImportError) as excinfo:
        pm.load_plugin('doesnt_exist')
    assert str(excinfo.value) == "No module named doesnt_exist"
Beispiel #7
0
def test_broken_plugin_manager():
    plugin_dir = os.path.join(ROOT_DIR, "data", "mock_plugin")
    pm = PluginManager(plugin_dir)
    with pytest.raises(ImportError) as excinfo:
        pm.load_plugin('broken_plugin')
    assert str(excinfo.value) == "Plug-in must have an 'init_plugin' method"