test(s52): cover build_notifier console/file dispatch + file-without-path fail-fast

This commit is contained in:
Kjell Tore Guttormsen 2026-07-17 03:16:25 +02:00
commit cd8553c7ee

View file

@ -132,6 +132,21 @@ def test_config_fail_fast() -> None:
assert isinstance(notifier, WebhookNotifier)
def test_build_notifier_dispatches_console_and_file(tmp_path) -> None:
"""Factory-glue coverage (the units are tested above): the console and file branches return
the right notifier types, and a file config without a path is rejected at CONSTRUCTION
(guards ``_required_fields_by_type`` the ``assert config.path is not None`` in
``build_notifier`` is unreachable by construction). RED only if dispatch/validator break
e.g. the file branch returning ConsoleNotifier flips the isinstance."""
assert isinstance(build_notifier(NotifierConfig(type="console")), ConsoleNotifier)
assert isinstance(
build_notifier(NotifierConfig(type="file", path=str(tmp_path / "out.jsonl"))),
FileNotifier,
)
with pytest.raises(ValidationError):
NotifierConfig(type="file") # path missing → model_validator raises
def test_webhook_config_rejects_schemeless_url() -> None:
"""Fail-fast scheme gate (S5.2 remediation): a scheme-less webhook url is rejected at config
construction BEFORE it can reach ``_urllib_post``, whose bare ``ValueError`` would carry the