test_stamp_atomic.py python
35 lines 1.3 KB
Raw
sha256:8461d44b77376fbf06fa7c3e085d309e3010fd8d5886d63c63e69ce118811ad4 docs: record AFF-b feature-tip SHAs after AFF-b-ISR commit. Human 3 days 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 produced_by="checklist_engine",
27 provider_kind="rule_engine",
28 checklist_ids=["C1"],
29 checklist_source="builtin",
30 findings_count=0,
31 )
32 with patch("tools.freeze_reviewer.stamp.atomic_write_text", side_effect=WriteFailure(path, OSError("fail"))):
33 with pytest.raises(WriteFailure):
34 write_stamp(path, parsed, stamp)
35 assert path.read_text(encoding="utf-8") == original
File History 1 commit
sha256:8461d44b77376fbf06fa7c3e085d309e3010fd8d5886d63c63e69ce118811ad4 docs: record AFF-b feature-tip SHAs after AFF-b-ISR commit. Human 3 days ago