test(s53): main()-level --verdict-dir coverage (already-wired flags confirmed, not re-wired)
SC2 second half: --verdict-dir had no main()-level test (exploration gap). New test drops one valid verdict into a tmp inbox and drives main([pid, --docs-dir, --bundle-dir, --verdict-dir, --live-dry-run]) -> rc 0: the inbox ingestion (load_verdicts_from_dir, run.py:287) runs before the dry-run cut (run.py:335), so the flag's wiring is exercised offline without raising. --bundle-dir's main()-level coverage already exists in test_live_dry_run.py and is referenced, not duplicated. run.py untouched (never re-wired). 11 passed in test_run_cli.py. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KNNiJRk1sSwxgVLS5AobT1
This commit is contained in:
parent
1b990f0887
commit
5f8a91175a
1 changed files with 34 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ import pytest
|
|||
from portfolio_optimiser import run
|
||||
from portfolio_optimiser.dimension import Dimension
|
||||
from portfolio_optimiser.ledger import LedgerEntry, SavingsLedger
|
||||
from portfolio_optimiser.verdicts import ProposalFeatures, capture_verdict, write_verdict
|
||||
|
||||
BUNDLE_DIR = Path(__file__).resolve().parents[1] / "shared" / "examples" / "bygg-energi-mikro"
|
||||
_PID = "BYGG-KONTOR-NORD"
|
||||
|
|
@ -232,3 +233,36 @@ def test_legacy_single_project_invocation_still_succeeds(capsys) -> None:
|
|||
)
|
||||
assert rc == 0
|
||||
assert "LIVE-DRY-RUN OK" in capsys.readouterr().out
|
||||
|
||||
|
||||
# --- Step 5: confirm coverage for the already-wired flags (never re-wired; run.py untouched) ------
|
||||
|
||||
|
||||
def test_verdict_dir_ingested_at_main_level_offline(tmp_path, capsys) -> None:
|
||||
"""Step 5 (SC2 second half): ``--verdict-dir`` is exercised at ``main()`` level — the previously
|
||||
untested already-wired flag. The async inbox is ingested (``load_verdicts_from_dir``,
|
||||
``run.py:287``) BEFORE the dry-run cut (``run.py:335``), so a dropped verdict is threaded through
|
||||
``main()`` offline without raising. ``--bundle-dir``'s ``main()``-level coverage already exists
|
||||
in ``tests/test_live_dry_run.py:32-49`` and is NOT re-tested here (never re-wired)."""
|
||||
inbox = tmp_path / "inbox"
|
||||
feats = ProposalFeatures(
|
||||
affected_codes=frozenset({"ENERGI-TOTAL-EL"}),
|
||||
measure_type="energy_efficiency",
|
||||
claimed_saving_nok=30000.0,
|
||||
description="LED-retrofit",
|
||||
)
|
||||
write_verdict(str(inbox), capture_verdict(feats, "approved", "expert reviewed (sim)"))
|
||||
rc = run.main(
|
||||
[
|
||||
_PID,
|
||||
"--docs-dir",
|
||||
str(BUNDLE_DIR),
|
||||
"--bundle-dir",
|
||||
str(BUNDLE_DIR),
|
||||
"--verdict-dir",
|
||||
str(inbox),
|
||||
"--live-dry-run",
|
||||
]
|
||||
)
|
||||
assert rc == 0
|
||||
assert "LIVE-DRY-RUN OK" in capsys.readouterr().out
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue