47 lines
2.0 KiB
Python
47 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Tests for the S6-01 full simulation gap audit."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
import generate_full_linuxcnc_simulation_gap_audit
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
REPORT = ROOT / "coverage/full-linuxcnc-simulation-gap-audit.report.json"
|
|
|
|
|
|
class FullLinuxCncSimulationGapAuditTests(unittest.TestCase):
|
|
def test_contract(self):
|
|
report = json.loads(REPORT.read_text(encoding="utf-8"))
|
|
self.assertEqual(report["schema"], "full-linuxcnc-simulation-gap-audit.v1")
|
|
self.assertEqual(report["task_id"], "S6-01")
|
|
self.assertEqual(report["status"], "verified")
|
|
self.assertGreaterEqual(report["audit_scope"]["p0_p8_task_count"], 30)
|
|
self.assertEqual(report["source_test_summary"]["tasks"], ["S5-01", "S5-02", "S5-03", "S5-04", "S5-05", "S5-06", "S5-07", "S5-08"])
|
|
self.assertEqual(report["next_execution"]["task_id"], "S6-02")
|
|
self.assertTrue(any(item["gap_id"] == "GAP-TASK-TICK-INTEGRATION" for item in report["gap_ledger"]))
|
|
self.assertTrue(any(item["evidence_state"] == "NO_DIRECT_REPORT" for item in report["task_ledger"]["tasks"]))
|
|
|
|
def test_self_hash(self):
|
|
report = json.loads(REPORT.read_text(encoding="utf-8"))
|
|
unsigned = {key: value for key, value in report.items() if key != "report_sha256"}
|
|
self.assertEqual(report["report_sha256"], hashlib.sha256(generate_full_linuxcnc_simulation_gap_audit.canonical(unsigned).encode()).hexdigest())
|
|
|
|
def test_deterministic(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
first = generate_full_linuxcnc_simulation_gap_audit.generate(ROOT, Path(directory) / "one.json")
|
|
second = generate_full_linuxcnc_simulation_gap_audit.generate(ROOT, Path(directory) / "two.json")
|
|
self.assertEqual(first, second)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|