"""IMP-#91 u14 — unit tests for the status-board marker updater. Exercises ``parse_outcomes`` (nodeid → axis/mdx outcome mapping) and ``update_board_text`` (idempotent marker rewrite). u15 will wire the CLI into the GitHub Actions workflow; these tests guard the contract. """ from __future__ import annotations import sys from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(REPO_ROOT / "scripts")) import update_status_board as usb # noqa: E402 SAMPLE_REPORT = { "tests": [ { "nodeid": "tests/integration/test_multi_mdx_regression.py::test_normalize_snapshot_matches[01]", "outcome": "passed", }, { "nodeid": "tests/integration/test_multi_mdx_regression.py::test_v4_ranking_snapshot_matches[02]", "outcome": "passed", }, { "nodeid": "tests/integration/test_multi_mdx_regression.py::test_layout_snapshot_matches[03]", "outcome": "failed", }, { "nodeid": "tests/integration/test_multi_mdx_regression.py::test_pipeline_run_produces_step20_status[02]", "outcome": "passed", }, ] } def test_parse_outcomes_maps_known_axes_only() -> None: outcomes = usb.parse_outcomes(SAMPLE_REPORT) assert outcomes == { ("F0", "01"): "PASS", ("F1", "02"): "PASS", ("F4", "03"): "FAIL", } def test_update_board_text_rewrites_markers() -> None: board = "F0/01: ? F1/02: old" outcomes = {("F0", "01"): "PASS"} result = usb.update_board_text(board, outcomes) assert "PASS" in result assert "?" in result def test_update_board_text_is_idempotent() -> None: board = "old" outcomes = {("F2", "05"): "PASS"} once = usb.update_board_text(board, outcomes) twice = usb.update_board_text(once, outcomes) assert once == twice == "PASS"