Files
linuxcncWebWASM/scripts/test_python_callbacks_report.py

28 lines
940 B
Python

import hashlib
import json
import unittest
from pathlib import Path
import generate_python_callbacks_report
ROOT = Path(__file__).resolve().parents[1]
class PythonCallbacksReportTests(unittest.TestCase):
def test_report(self):
report = json.loads((ROOT / "coverage/python-callbacks.report.json").read_text(encoding="utf-8"))
self.assertEqual(report["schema"], "python-callbacks-report.v1")
self.assertEqual(report["status"], "verified")
self.assertEqual(report["limits"]["reentrant"], "blocked")
def test_report_self_hash(self):
report = json.loads((ROOT / "coverage/python-callbacks.report.json").read_text(encoding="utf-8"))
unsigned = dict(report)
actual = unsigned.pop("report_sha256")
self.assertEqual(actual, hashlib.sha256(generate_python_callbacks_report.canonical(unsigned).encode("utf-8")).hexdigest())
if __name__ == "__main__":
unittest.main()