Exemplo n.º 1
0
def test_call_factory(plugin_package):
    """Test that the call factory can retrieve call in package"""
    plugin_name = "plugin_parts"
    call = pyplugs.call_factory(plugin_package)
    factory_call = call(plugin_name)
    pyplugs_call = pyplugs.call(plugin_package, plugin=plugin_name)
    assert factory_call == pyplugs_call
Exemplo n.º 2
0
def test_call_non_existing_plugin():
    """Test that calling a non-existing plugin raises an error"""
    with pytest.raises(pyplugs.UnknownPluginError):
        pyplugs.call("pyplugs", "non_existent")
Exemplo n.º 3
0
def test_call_existing_plugin(plugin_package):
    """Test that calling a test-plugin works, and returns a string"""
    plugin_name = pyplugs.names(plugin_package)[0]
    return_value = pyplugs.call(plugin_package, plugin_name)
    assert isinstance(return_value, str)
Exemplo n.º 4
0
def test_call_non_existing_func(plugin_package):
    """Test that calling a non-existing plug-in function raises an error"""
    plugin_name = "plugin_parts"
    func_name = "non_existent"
    with pytest.raises(pyplugs.UnknownPluginFunctionError):
        pyplugs.call(plugin_package, plugin_name, func=func_name)
Exemplo n.º 5
0
def test_default_part(plugin_package):
    """Test that first registered function in a plugin is called by default"""
    plugin_name = "plugin_parts"
    default = pyplugs.call(plugin_package, plugin_name)
    explicit = pyplugs.call(plugin_package, plugin_name, func="plugin_default")
    assert default == explicit
Exemplo n.º 6
0
def test_call_with_label(plugin_package):
    """Test that labels are accounted for when calling plugins"""
    assert pyplugs.call(plugin_package, "plugin_labels",
                        label="label") == "first"
def get_view(app, view):
    """Get a view from a given app"""
    with Timer(text=f"Added view {app}:{view} in {{:.2f}} seconds",
               logger=logger.time):
        return pyplugs.call(package=f"{__package__}.{app}", plugin=view)