test_findings_verdict.py python
56 lines 2.1 KB
Raw
sha256:8d7f41aafae41deee70035a92f93602ef1722a290153597451e5932af503a42c docs: queue board-identity follow-ups so they survive the session Human 4 hours ago
1 """Unit tests for findings, verdicts, citations (§K5.6)."""
2
3 from __future__ import annotations
4
5 from tools.freeze_reviewer.findings import (
6 assign_finding_ids,
7 derive_verdict,
8 validate_and_repair_findings,
9 verdict_exit_code,
10 )
11 from tools.freeze_reviewer.types import Finding
12
13
14 def test_zero_findings_pass() -> None:
15 assert derive_verdict([], human_escalation=["security"]) == "pass"
16 assert verdict_exit_code("pass") == 0
17
18
19 def test_major_only_findings() -> None:
20 findings = [
21 Finding(check="C1", severity="MAJOR", category="completeness", path="docs/a.md", line=2, message="x").with_citation()
22 ]
23 assert derive_verdict(findings, human_escalation=["security"]) == "findings"
24 assert verdict_exit_code("findings") == 7
25
26
27 def test_blocker_blocked() -> None:
28 findings = [
29 Finding(check="C2", severity="BLOCKER", category="completeness", path="docs/a.md", line=1, message="x").with_citation()
30 ]
31 assert derive_verdict(findings, human_escalation=[]) == "blocked"
32 assert verdict_exit_code("blocked") == 8
33
34
35 def test_escalation_category_blocked_even_if_major() -> None:
36 findings = [
37 Finding(check="C4", severity="MAJOR", category="security", path="docs/a.md", line=3, message="x").with_citation()
38 ]
39 assert derive_verdict(findings, human_escalation=["security"]) == "blocked"
40
41
42 def test_uncited_finding_becomes_synthetic_blocked() -> None:
43 raw = [Finding(check="C1", severity="MAJOR", category="other", path="", line=0, message="bad")]
44 repaired = validate_and_repair_findings(raw, artifact_path="docs/a.md")
45 assert repaired[0].severity == "BLOCKER"
46 assert repaired[0].citation == "docs/a.md:1"
47
48
49 def test_stable_sort_and_ids() -> None:
50 findings = [
51 Finding(check="C2", severity="MINOR", category="other", path="docs/b.md", line=1, message="b").with_citation(),
52 Finding(check="C1", severity="MAJOR", category="other", path="docs/a.md", line=5, message="a").with_citation(),
53 ]
54 assigned = assign_finding_ids(findings)
55 assert [item.id for item in assigned] == ["F1", "F2"]
56 assert assigned[0].path == "docs/a.md"
File History 1 commit
sha256:8d7f41aafae41deee70035a92f93602ef1722a290153597451e5932af503a42c docs: queue board-identity follow-ups so they survive the session Human 4 hours ago