test(metrics): fix attestation-event test freshness time-bomb (use now vs hardcoded date)
This commit is contained in:
@@ -205,11 +205,15 @@ def test_attestation_event_emission(tmp_metrics):
|
||||
# Dev skips (autonomous) — no event
|
||||
ok, reason = attest("cid-attest-1", "dev", "testuser")
|
||||
assert ok
|
||||
# QA requires approver + attestation matrix — mock evidence
|
||||
# QA requires approver + attestation matrix — mock evidence with
|
||||
# fresh timestamps (relative to now, not hardcoded — avoids the
|
||||
# time-bomb where fixed dates age out of the freshness window).
|
||||
import datetime
|
||||
now = datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
ok, reason = attest("cid-attest-2", "qa", "testuser",
|
||||
evidence={"functional_correctness": {"timestamp": "2026-08-04T12:00:00Z", "type": "test", "payload": {}},
|
||||
"performance_baseline": {"timestamp": "2026-08-04T12:00:00Z", "type": "test", "payload": {}},
|
||||
"security_posture": {"timestamp": "2026-08-04T12:00:00Z", "type": "test", "payload": {}},
|
||||
evidence={"functional_correctness": {"timestamp": now, "type": "test", "payload": {}},
|
||||
"performance_baseline": {"timestamp": now, "type": "test", "payload": {}},
|
||||
"security_posture": {"timestamp": now, "type": "test", "payload": {}},
|
||||
"contract_nfrs": {"valid": True}})
|
||||
assert ok
|
||||
# Check the attestation event was emitted
|
||||
|
||||
Reference in New Issue
Block a user