25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Contract tests for S8-09 runtime extension aggregation."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
REPORT = ROOT / "coverage/runtime-extensions-s8-09.report.json"
|
|
|
|
|
|
class RuntimeExtensionsS809Tests(unittest.TestCase):
|
|
def test_contract(self) -> None:
|
|
report = json.loads(REPORT.read_text(encoding="utf-8")); self.assertEqual(report["schema"], "runtime-extensions-s8-09-report.v1"); self.assertEqual(report["status"], "verified"); self.assertEqual(report["counts"]["failed"], 0); self.assertEqual(report["counts"]["passed"], report["counts"]["runners"])
|
|
|
|
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"}; canonical = json.dumps(unsigned, ensure_ascii=False, sort_keys=True, separators=(",", ":")); self.assertEqual(report["report_sha256"], hashlib.sha256(canonical.encode()).hexdigest())
|
|
|
|
|
|
if __name__ == "__main__": unittest.main()
|