Example #1
0
def test_plugin_manager_add(mock_plugin):
    """Add a plugin to the Manager."""
    pm = plugin.PluginManager()
    assert len(pm.plugins) == 0
    pm.add(mock_plugin)
    assert len(pm.plugins) == 1
    assert 'test-plug' in pm.plugins
Example #2
0
def test_plugin_manager_add(mock_plugin):
    """Add a plugin to the Manager."""
    pm = plugin.PluginManager()
    assert len(pm.plugins) == 0
    pm.add(mock_plugin)
    assert len(pm.plugins) == 1
    assert '+tcp@localhost:9999' in pm.plugins
Example #3
0
def test_plugin_manager_remove(mock_plugin):
    """Remove a plugin from the Manager."""
    pm = plugin.PluginManager()
    pm.plugins['test-plug'] = mock_plugin
    assert len(pm.plugins) == 1
    assert 'test-plug' in pm.plugins

    pm.remove('test-plug')
    assert len(pm.plugins) == 0
    assert 'test-plug' not in pm.plugins
Example #4
0
def test_plugin_manager_remove_nonexistent():
    """Remove a plugin from the Manager that is not there."""
    pm = plugin.PluginManager()
    assert len(pm.plugins) == 0
    pm.remove('test')
    assert len(pm.plugins) == 0
Example #5
0
def test_plugin_manager_add_already_exists(mock_plugin):
    """Add a plugin that is already managed by the Manager."""
    pm = plugin.PluginManager()
    pm.plugins['test-plug'] = 'foo'
    with pytest.raises(errors.PluginStateError):
        pm.add(mock_plugin)
Example #6
0
def test_plugin_manager_add_invalid():
    """Add an invalid plugin (a string is not a valid plugin)."""
    pm = plugin.PluginManager()
    with pytest.raises(errors.PluginStateError):
        pm.add('plugin')
Example #7
0
def test_plugin_manager_get_no_value():
    """Get a plugin that is not managed by the Manager."""
    pm = plugin.PluginManager()
    assert pm.get('test') is None
Example #8
0
def test_plugin_manager_get():
    """Get a value from the Plugin Manager."""
    pm = plugin.PluginManager()
    pm.plugins['test'] = 'foo'
    assert pm.get('test') == 'foo'