36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Contract tests for FE-M4 GUI source inventory."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
import generate_gui_source_inventory
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
REPORT = ROOT / "coverage/gui-source-inventory-fe-m4.report.json"
|
|
|
|
|
|
class GuiSourceInventoryTests(unittest.TestCase):
|
|
def test_contract(self) -> None:
|
|
report = json.loads(REPORT.read_text(encoding="utf-8"))
|
|
self.assertEqual(report["schema"], "gui-source-inventory-fe-m4-report.v1")
|
|
self.assertEqual(report["task_id"], "FE-M4-GUI-01")
|
|
self.assertEqual(report["status"], "verified")
|
|
self.assertGreater(report["counts"]["records"], 1000)
|
|
self.assertGreaterEqual(len(report["counts"]["families"]), 8)
|
|
self.assertEqual(report["checks"]["source_hashes"]["status"], "verified")
|
|
|
|
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_gui_source_inventory.canonical(unsigned).encode()).hexdigest())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|