mirror of
https://github.com/zensical/zensical.git
synced 2026-09-24 15:25:40 +00:00
fix: relax validation of autorefs settings
Signed-off-by: Timothée Mazzucotelli <dev@pawamoy.fr>
This commit is contained in:
Vendored
+7
-1
@@ -572,8 +572,14 @@ class TestPluginShimming:
|
||||
)
|
||||
|
||||
def test_autorefs_standalone(self, tmp_path: Path) -> None:
|
||||
config = self._parse_yaml(tmp_path, plugins={"autorefs": {}})
|
||||
options = {
|
||||
"resolve_closest": True,
|
||||
"link_titles": "external",
|
||||
"strip_title_tags": False,
|
||||
}
|
||||
config = self._parse_yaml(tmp_path, plugins={"autorefs": options})
|
||||
assert AutorefsExtension.name in config["markdown_extensions"]
|
||||
assert config["plugins"]["autorefs"]["config"] == {}
|
||||
|
||||
def test_autorefs_disabled_not_added(
|
||||
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||
|
||||
+14
@@ -265,6 +265,20 @@ def test_accepts_supported_shim_options(
|
||||
assert plugins[name]["config"] == config
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"option", ["resolve_closest", "link_titles", "strip_title_tags"]
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"value", [True, False, "auto", "external", 42, [], {}, None]
|
||||
)
|
||||
def test_silently_discards_unsupported_autorefs_options(
|
||||
option: str, value: Any, capsys: pytest.CaptureFixture[str]
|
||||
) -> None:
|
||||
plugins = _convert_plugins({"autorefs": {"enabled": True, option: value}})
|
||||
assert plugins["autorefs"]["config"] == {"enabled": True}
|
||||
assert capsys.readouterr().err == ""
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("name", "config", "message"),
|
||||
[
|
||||
|
||||
@@ -1695,8 +1695,16 @@ def _convert_plugins(value: Any, config: dict) -> dict:
|
||||
# Validate settings forwarded by the plugin-to-extension shims.
|
||||
if "autorefs" in plugins:
|
||||
autorefs = plugins["autorefs"]
|
||||
_reject_unknown_options("autorefs", autorefs, {"enabled"})
|
||||
_reject_unknown_options(
|
||||
"autorefs",
|
||||
autorefs,
|
||||
{"enabled", "resolve_closest", "link_titles", "strip_title_tags"},
|
||||
)
|
||||
_validate_boolean_options("autorefs", autorefs, ("enabled",))
|
||||
# Ignore these upstream settings: the Rust resolver currently uses
|
||||
# fixed resolution and title behavior.
|
||||
for name in ("resolve_closest", "link_titles", "strip_title_tags"):
|
||||
autorefs.pop(name, None)
|
||||
|
||||
if "markdown-exec" in plugins:
|
||||
markdown_exec = plugins["markdown-exec"]
|
||||
|
||||
Reference in New Issue
Block a user