33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import datetime as dt
|
|
import importlib.util
|
|
from pathlib import Path
|
|
|
|
MODULE = Path(__file__).parents[1] / "tools/check_admission_freshness.py"
|
|
spec = importlib.util.spec_from_file_location("freshness", MODULE)
|
|
freshness = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(freshness)
|
|
|
|
|
|
def record(state="verified", status="pass", risk="open"):
|
|
return {
|
|
"checked_at": "2026-07-26T18:00:00Z",
|
|
"readiness_state": state,
|
|
"checks": {"compatibility": {"status": status}},
|
|
"residual_risks": [{"risk": "single node", "status": risk}],
|
|
}
|
|
|
|
|
|
def test_verified_may_retain_explicit_open_risk():
|
|
now = dt.datetime(2026, 7, 26, 19, tzinfo=dt.timezone.utc)
|
|
assert freshness.assess(record(), now, 24) == []
|
|
|
|
|
|
def test_production_approval_fails_closed():
|
|
now = dt.datetime(2026, 7, 26, 19, tzinfo=dt.timezone.utc)
|
|
failures = freshness.assess(record("production-approved", "unknown"), now, 24)
|
|
assert len(failures) == 2
|
|
|
|
|
|
def test_stale_evidence_fails():
|
|
now = dt.datetime(2026, 7, 28, 19, tzinfo=dt.timezone.utc)
|
|
assert "evidence is stale" in freshness.assess(record(), now, 24)
|