39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
REPORT = ROOT / "coverage/xyzac-trt-source-slice-inventory.report.json"
|
|
|
|
|
|
class XyzacSourceSliceTest(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
subprocess.run(["python3", "scripts/generate_xyzac_trt_source_slices.py"], cwd=ROOT, check=True, stdout=subprocess.PIPE, text=True)
|
|
cls.report = json.loads(REPORT.read_text(encoding="utf-8"))
|
|
|
|
def test_self_hash(self):
|
|
unsigned = dict(self.report)
|
|
actual = unsigned.pop("report_sha256")
|
|
canonical = json.dumps(unsigned, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
|
|
self.assertEqual(actual, hashlib.sha256(canonical.encode()).hexdigest())
|
|
|
|
def test_source_slice_closure(self):
|
|
self.assertEqual(self.report["counts"]["unregistered_slices"], 0)
|
|
self.assertTrue(self.report["checks"]["all_controls_commands_states_have_slice_id"])
|
|
self.assertTrue(all(row["source"]["sha256"] for row in self.report["slices"]))
|
|
|
|
def test_authority_and_required_rtcp(self):
|
|
self.assertEqual(self.report["authority"]["js_authority"], 0)
|
|
ids = {row["slice_id"] for row in self.report["slices"]}
|
|
self.assertIn("AXIS-XYZAC-M428-M429-M430", ids)
|
|
self.assertIn("AXIS-XYZAC-KINEMATICS", ids)
|
|
self.assertEqual(self.report["release_status"], "STOP_RELEASE")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|