test(chronology): write Red tests for quality gate (4 checks)
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
from scripts.audit.chronology_quality_gate import run_quality_gate, QualityGateResult
|
||||
|
||||
|
||||
def _make_row(status: str, confidence: str, reason: str, summary: str) -> dict:
|
||||
return {
|
||||
"status": status,
|
||||
"confidence": confidence,
|
||||
"reason": reason,
|
||||
"summary": summary,
|
||||
"track_id": "test_track",
|
||||
"date": "2026-07-01",
|
||||
"folder_link": "conductor/tracks/test_track",
|
||||
"init_sha": "abc1234",
|
||||
"end_sha": "def5678",
|
||||
"commit_count": 1,
|
||||
}
|
||||
|
||||
|
||||
def test_quality_gate_passes_on_good_rows() -> None:
|
||||
rows = [
|
||||
_make_row("Completed", "high", "completion report found", "A real summary."),
|
||||
_make_row("Completed", "medium", "3 work commits", "Another real summary."),
|
||||
_make_row("Active", "medium", "0 work commits in tracks/", "Spec-only track."),
|
||||
]
|
||||
result = run_quality_gate(rows)
|
||||
assert result.passed is True
|
||||
assert result.violations == []
|
||||
|
||||
|
||||
def test_quality_gate_fails_on_too_many_needs_review() -> None:
|
||||
rows = [
|
||||
_make_row("Needs Review", "none", "inconclusive", "Summary 1."),
|
||||
_make_row("Needs Review", "none", "inconclusive", "Summary 2."),
|
||||
_make_row("Completed", "high", "completion report", "Summary 3."),
|
||||
]
|
||||
result = run_quality_gate(rows)
|
||||
assert result.passed is False
|
||||
assert any("Needs Review" in v for v in result.violations)
|
||||
|
||||
|
||||
def test_quality_gate_fails_on_zero_completed() -> None:
|
||||
rows = [
|
||||
_make_row("Active", "medium", "0 work commits", "Summary 1."),
|
||||
_make_row("Active", "medium", "0 work commits", "Summary 2."),
|
||||
]
|
||||
result = run_quality_gate(rows)
|
||||
assert result.passed is False
|
||||
assert any("0 rows are Completed" in v for v in result.violations)
|
||||
|
||||
|
||||
def test_quality_gate_fails_on_metadata_field_summaries() -> None:
|
||||
rows = [
|
||||
_make_row("Completed", "high", "completion report", "Real summary."),
|
||||
_make_row("Completed", "high", "completion report", "**Priority:** A (foundational)"),
|
||||
]
|
||||
result = run_quality_gate(rows)
|
||||
assert result.passed is False
|
||||
assert any("metadata-field" in v for v in result.violations)
|
||||
|
||||
|
||||
def test_quality_gate_fails_on_empty_reason() -> None:
|
||||
rows = [
|
||||
_make_row("Completed", "high", "", "Real summary."),
|
||||
]
|
||||
result = run_quality_gate(rows)
|
||||
assert result.passed is False
|
||||
assert any("empty reason" in v for v in result.violations)
|
||||
|
||||
|
||||
def test_quality_gate_strict_mode_exits_nonzero() -> None:
|
||||
rows = [_make_row("Active", "medium", "0 work commits", "Summary.")]
|
||||
result = run_quality_gate(rows)
|
||||
assert result.passed is False
|
||||
assert result.exit_code == 1
|
||||
Reference in New Issue
Block a user