29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Contract tests for S8-08 machine-family report."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
import sys
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
import generate_machine_families_s8_08
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
REPORT = ROOT / "coverage/machine-families-s8-08.report.json"
|
|
|
|
|
|
class MachineFamiliesS808Tests(unittest.TestCase):
|
|
def test_contract(self) -> None:
|
|
report = json.loads(REPORT.read_text(encoding="utf-8")); self.assertEqual(report["schema"], "machine-families-s8-08-report.v1"); self.assertEqual(report["status"], "verified"); self.assertEqual(report["checks"]["delta_joints"]["lineardelta"], [300, 300, 300]); self.assertEqual(report["checks"]["delta_joints"]["rotarydelta"], [10, 10, 10])
|
|
|
|
def test_self_hash(self) -> None:
|
|
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_machine_families_s8_08.canonical(unsigned).encode()).hexdigest())
|
|
|
|
|
|
if __name__ == "__main__": unittest.main()
|