test_stamp_atomic.py python
30 lines 1.1 KB
Raw
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor ⚠ breaking 22 hours ago
1 """Data-integrity tests for atomic stamp writes (§K5.12)."""
2
3 from __future__ import annotations
4
5 from pathlib import Path
6 from unittest.mock import patch
7
8 import pytest
9
10 from cli.atomic import WriteFailure
11 from tests.support import FIXTURES
12 from tools.freeze_reviewer.artifact import parse_artifact
13 from tools.freeze_reviewer.stamp import build_stamp, write_stamp
14 from tools.freeze_reviewer.types import ReviewerSettings
15
16
17 def test_oserror_mid_stamp_preserves_original(tmp_path: Path) -> None:
18 path = tmp_path / "freeze.yaml"
19 original = (FIXTURES / "freeze-artifact.yaml").read_text(encoding="utf-8")
20 path.write_text(original, encoding="utf-8")
21 parsed = parse_artifact(path, rel_path="freeze.yaml")
22 stamp = build_stamp(
23 parsed,
24 reviewer=ReviewerSettings("agent", "thinking-high", "local", "human"),
25 kit_version="0.1.0",
26 )
27 with patch("tools.freeze_reviewer.stamp.atomic_write_text", side_effect=WriteFailure(path, OSError("fail"))):
28 with pytest.raises(WriteFailure):
29 write_stamp(path, parsed, stamp)
30 assert path.read_text(encoding="utf-8") == original
File History 1 commit
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor 22 hours ago