Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 236506@bnt-lap001 Assistant-Session: 09087018-91e1-48c5-ab2f-acfbb62c92e4
35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
"""The E2 receipt generator emits a receipt the sender lane accepts as T03."""
|
|
import importlib.util
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
from datetime import UTC, datetime
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def lane():
|
|
sys.path.insert(0, str(ROOT / "scripts"))
|
|
spec = importlib.util.spec_from_file_location("lane_e2", ROOT / "scripts/audit_core_synthetic_sender_lane.py")
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
def test_receipt_is_accepted_by_the_lane_as_t03(tmp_path):
|
|
out = tmp_path / "approval.json"
|
|
printed = json.loads(subprocess.run([sys.executable, str(ROOT / "scripts/rpf-wp-0015-e2-receipt.py"), str(out)],
|
|
check=True, capture_output=True, text=True).stdout)
|
|
m = lane()
|
|
approval, spec = m.load_receipt(out, datetime.now(UTC), require_open_window=True)
|
|
assert approval["task_id"] == "RAILIANCE-WP-0024-T03"
|
|
assert printed["confirm"] == m.confirm_token(approval)
|
|
|
|
|
|
def test_refuses_to_overwrite(tmp_path):
|
|
out = tmp_path / "approval.json"
|
|
out.write_text("{}")
|
|
result = subprocess.run([sys.executable, str(ROOT / "scripts/rpf-wp-0015-e2-receipt.py"), str(out)],
|
|
capture_output=True, text=True)
|
|
assert result.returncode != 0 and out.read_text() == "{}"
|