Implement AXIS parity UI and execution baseline
This commit is contained in:
45
scripts/test_sim_case_catalog.py
Normal file
45
scripts/test_sim_case_catalog.py
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Validate the generated configs/sim catalog identity and status coverage."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import json
|
||||
import hashlib
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
CATALOG = ROOT / "web/workspace/sim-case-catalog.mjs"
|
||||
REPORT = ROOT / "coverage/sim-case-catalog.report.json"
|
||||
|
||||
|
||||
class SimCaseCatalogTests(unittest.TestCase):
|
||||
def test_generated_catalog_shape(self) -> None:
|
||||
text = CATALOG.read_text(encoding="utf-8")
|
||||
self.assertIn('SIM_CASE_CATALOG_SCHEMA = "linuxcnc-sim-case-catalog.v1"', text)
|
||||
self.assertRegex(text, r"SIM_CASE_CATALOG = Object\.freeze\(\[")
|
||||
self.assertRegex(text, r"SIM_FILE_INDEX = Object\.freeze\(\[")
|
||||
self.assertIn("linuxcnc/configs/sim/axis/minimal_xyz.ini", text)
|
||||
self.assertIn("linuxcnc/configs/sim/axis/corexy/corexy_by_hal.ini", text)
|
||||
self.assertIn("linuxcnc/lib/hallib/basic_sim.tcl", text)
|
||||
self.assertIn("linuxcnc/linuxcnc.gif", text)
|
||||
|
||||
def test_catalog_case_count(self) -> None:
|
||||
text = CATALOG.read_text(encoding="utf-8")
|
||||
count = int(re.search(r'"case_count":(\d+)', text).group(1))
|
||||
file_count = int(re.search(r'"file_count":(\d+)', text).group(1))
|
||||
self.assertEqual(count, 235)
|
||||
self.assertGreater(file_count, count)
|
||||
|
||||
def test_report_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"}
|
||||
canonical = json.dumps(unsigned, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
|
||||
self.assertEqual(report["report_sha256"], hashlib.sha256(canonical.encode("utf-8")).hexdigest())
|
||||
self.assertEqual(report["status"], "verified")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user