def test_manually_set_plugins():
    assert get_plugins() == OrderedDict()
    p1 = LightbusPlugin()
    p2 = LightbusPlugin()
    manually_set_plugins(OrderedDict([
        ('p1', p1),
        ('p2', p2),
    ]))
    assert get_plugins() == OrderedDict([
        ('p1', p1),
        ('p2', p2),
    ])
def test_is_plugin_loaded():
    assert get_plugins() == OrderedDict()
    assert is_plugin_loaded(LightbusPlugin) == False
    manually_set_plugins(OrderedDict([
        ('p1', LightbusPlugin()),
    ]))
    assert is_plugin_loaded(LightbusPlugin) == True
def test_remove_all_plugins():
    assert get_plugins() == OrderedDict()
    manually_set_plugins(OrderedDict([
        ('p1', LightbusPlugin()),
    ]))
    remove_all_plugins()
    assert get_plugins() == OrderedDict()
Example #4
0
async def test_execute_hook(mocker, plugin_registry: PluginRegistry):
    """Ensure calling execute_hook() calls the method on the plugin"""
    assert not plugin_registry._plugins
    plugin = LightbusPlugin()
    plugin_registry.set_plugins([plugin])

    async def dummy_coroutine(*args, **kwargs):
        pass

    m = mocker.patch.object(plugin, "before_worker_start", return_value=dummy_coroutine())

    await plugin_registry.execute_hook("before_worker_start", client=None, loop=None)
    assert m.called
async def test_plugin_hook(mocker):
    """Ensure calling plugin_hook() calls the method on the plugin"""
    assert get_plugins() == OrderedDict()
    plugin = LightbusPlugin()
    manually_set_plugins(OrderedDict([
        ('p1', plugin),
    ]))

    async def dummy_coroutine(*args, **kwargs):
        pass
    m = mocker.patch.object(plugin, 'before_server_start', return_value=dummy_coroutine())

    await plugin_hook('before_server_start', bus_client=None, loop=None)
    assert m.called
 def do_add_base_plugin():
     manually_set_plugins(plugins={"base": LightbusPlugin()})
Example #7
0
 def do_add_base_plugin():
     dummy_bus.client.plugin_registry.set_plugins([LightbusPlugin()])
Example #8
0
def test_is_plugin_loaded():
    assert get_plugins() is None
    assert is_plugin_loaded(LightbusPlugin) == False
    manually_set_plugins(OrderedDict([("p1", LightbusPlugin())]))
    assert is_plugin_loaded(LightbusPlugin) == True
Example #9
0
def test_remove_all_plugins():
    assert get_plugins() is None
    manually_set_plugins(OrderedDict([("p1", LightbusPlugin())]))
    remove_all_plugins()
    assert get_plugins() is None
Example #10
0
def test_manually_set_plugins():
    assert get_plugins() is None
    p1 = LightbusPlugin()
    p2 = LightbusPlugin()
    manually_set_plugins(OrderedDict([("p1", p1), ("p2", p2)]))
    assert get_plugins() == OrderedDict([("p1", p1), ("p2", p2)])
Example #11
0
def test_is_plugin_loaded(plugin_registry: PluginRegistry):
    assert plugin_registry.is_plugin_loaded(LightbusPlugin) == False
    plugin_registry.set_plugins([LightbusPlugin()])
    assert plugin_registry.is_plugin_loaded(LightbusPlugin) == True
Example #12
0
def test_manually_set_plugins(plugin_registry: PluginRegistry):
    assert not plugin_registry._plugins
    p1 = LightbusPlugin()
    p2 = LightbusPlugin()
    plugin_registry.set_plugins([p1, p2])
    assert plugin_registry._plugins == [p1, p2]