Files
galaxy/test/unit/util/test_plugin_config.py
mvdbeek def95c9a21 Report unknown plugin types from dict configs by name
A dict-based plugin config (e.g. dependency_resolvers in galaxy.yml)
naming an unknown plugin type failed with a bare KeyError. Raise the
same "Failed to find plugin of type" error the XML loader raises.
2026-11-01 11:59:46 +01:00

37 lines
1.1 KiB
Python

from typing import Any
import pytest
from galaxy.util import parse_xml_string
from galaxy.util.plugin_config import (
load_plugins,
PluginConfigSource,
)
class KnownPlugin:
def __init__(self, **kwds: Any) -> None:
self.kwds = kwds
PLUGINS = {"known": KnownPlugin}
def test_load_plugins_from_dicts() -> None:
source = PluginConfigSource("dict", [{"type": "known", "foo": "bar"}])
(plugin,) = load_plugins(PLUGINS, source, {"extra": 1})
assert isinstance(plugin, KnownPlugin)
assert plugin.kwds == {"type": "known", "foo": "bar", "extra": 1}
def test_load_plugins_from_dicts_unknown_type() -> None:
source = PluginConfigSource("dict", [{"type": "homebrew"}])
with pytest.raises(Exception, match=r"Failed to find plugin of type \[homebrew\] in available plugin types"):
load_plugins(PLUGINS, source)
def test_load_plugins_from_element_unknown_type() -> None:
source = PluginConfigSource("xml", parse_xml_string("<plugins><homebrew /></plugins>"))
with pytest.raises(Exception, match=r"Failed to find plugin of type \[homebrew\] in available plugin types"):
load_plugins(PLUGINS, source)