Complete 3axis tutorial native and Web/WASM parity tools
This commit is contained in:
32
scripts/test_axis3_tool_comparison.py
Normal file
32
scripts/test_axis3_tool_comparison.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
REPORT = ROOT / "coverage/axis3-tutorial-native-web-tool-comparison.report.json"
|
||||
|
||||
|
||||
class Axis3ToolComparisonTests(unittest.TestCase):
|
||||
def test_contract(self) -> None:
|
||||
report = json.loads(REPORT.read_text(encoding="utf-8"))
|
||||
self.assertEqual(report["schema"], "axis3-tutorial-native-web-tool-comparison.v1")
|
||||
self.assertEqual(report["status"], "verified")
|
||||
self.assertEqual(report["conclusion"], "native_and_web_tools_match_selected_case_workflow")
|
||||
self.assertTrue(all(item["status"] == "verified" for item in report["checks"].values()))
|
||||
self.assertEqual(len(report["tools"]["native"]["screenshots"]), 4)
|
||||
self.assertEqual(len(report["tools"]["web"]["screenshots"]), 4)
|
||||
|
||||
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"}
|
||||
expected = hashlib.sha256(json.dumps(unsigned, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode()).hexdigest()
|
||||
self.assertEqual(report["report_sha256"], expected)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user