|
|
@@ -5,6 +5,7 @@ from __future__ import annotations
|
|
|
import copy
|
|
|
import hashlib
|
|
|
import json
|
|
|
+import sys
|
|
|
import zipfile
|
|
|
from pathlib import Path
|
|
|
from unittest import mock
|
|
|
@@ -14,9 +15,16 @@ from tests.unit.test_mse_r11_release_validation_bind import (
|
|
|
_validate,
|
|
|
_write_identity_zip,
|
|
|
)
|
|
|
+from tools import release_validation as rv
|
|
|
from tools import replay_semantic as rs
|
|
|
|
|
|
|
|
|
+def _patch_actual_replay(**kwargs):
|
|
|
+ """Patch the replay module actually imported by release_validation."""
|
|
|
+ mod = sys.modules[rv.bind_independent_replay.__module__]
|
|
|
+ return mock.patch.object(mod, "_run_actual_software_replay", **kwargs)
|
|
|
+
|
|
|
+
|
|
|
def _setup(tmp_path: Path):
|
|
|
review = tmp_path / "review.zip"
|
|
|
firmware = tmp_path / "firmware.zip"
|
|
|
@@ -264,7 +272,7 @@ def test_r15_independent_rerun_matches_sidecar(tmp_path: Path):
|
|
|
actual_sem["checked_files"] = 3
|
|
|
doc["replay_semantic_sha256"] = rs.semantic_sha256(actual_sem)
|
|
|
sidecars["review_detached_replay_json"].write_text(json.dumps(doc), encoding="utf-8")
|
|
|
- with mock.patch.object(rs, "_run_actual_software_replay", return_value=actual):
|
|
|
+ with _patch_actual_replay(return_value=actual):
|
|
|
result = _validate(tmp_path, review, firmware, sidecars)
|
|
|
assert result["status"] == "pass", result.get("failures")
|
|
|
assert claimed["unit_modules"] == actual_sem["unit_modules"]
|
|
|
@@ -281,7 +289,7 @@ def test_r15_independent_rerun_unit_mismatch_fail(tmp_path: Path):
|
|
|
sidecars["review_detached_replay_json"].write_text(json.dumps(doc), encoding="utf-8")
|
|
|
actual = _matching_source_software()
|
|
|
actual["unit"]["modules"][0]["module"] = "tests.unit.test_not_replayed"
|
|
|
- with mock.patch.object(rs, "_run_actual_software_replay", return_value=actual):
|
|
|
+ with _patch_actual_replay(return_value=actual):
|
|
|
result = _validate(tmp_path, review, firmware, sidecars)
|
|
|
_assert_fail(result, "replay_semantic_unit_mismatch")
|
|
|
|
|
|
@@ -305,7 +313,7 @@ def test_r15_independent_rerun_error_fail(tmp_path: Path):
|
|
|
doc = json.loads(sidecars["review_detached_replay_json"].read_text(encoding="utf-8"))
|
|
|
doc["package_content"]["checked_files"] = 3
|
|
|
sidecars["review_detached_replay_json"].write_text(json.dumps(doc), encoding="utf-8")
|
|
|
- with mock.patch.object(rs, "_run_actual_software_replay", side_effect=RuntimeError("extract")):
|
|
|
+ with _patch_actual_replay(side_effect=RuntimeError("extract")):
|
|
|
result = _validate(tmp_path, review, firmware, sidecars)
|
|
|
_assert_fail(result, "replay_actual_rerun_error")
|
|
|
|
|
|
@@ -319,7 +327,7 @@ def test_r15_semantic_checked_files_mismatch_fail(tmp_path: Path):
|
|
|
doc = json.loads(sidecars["review_detached_replay_json"].read_text(encoding="utf-8"))
|
|
|
doc["package_content"]["checked_files"] = 1
|
|
|
sidecars["review_detached_replay_json"].write_text(json.dumps(doc), encoding="utf-8")
|
|
|
- with mock.patch.object(rs, "_run_actual_software_replay", return_value=_matching_source_software()):
|
|
|
+ with _patch_actual_replay(return_value=_matching_source_software()):
|
|
|
result = _validate(tmp_path, review, firmware, sidecars)
|
|
|
_assert_fail(
|
|
|
result,
|