Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a06ba0-10aa-7ea0-b20a-4f3fac39efe9
70 lines
1.8 KiB
Python
70 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from rein_aharness.cli import main
|
|
from rein_aharness.close_outbox import CloseOutbox, CloseRequest
|
|
|
|
|
|
def test_close_outbox_status_reports_pending_and_sets_failure_exit(
|
|
tmp_path: Path,
|
|
capsys,
|
|
) -> None:
|
|
outbox = CloseOutbox(state_dir=tmp_path / "runtime-state")
|
|
outbox.enqueue(
|
|
CloseRequest(
|
|
run_id="run-1",
|
|
transaction_id="tx-1",
|
|
worker_id="worker-1",
|
|
action="complete",
|
|
result={"ok": True},
|
|
)
|
|
)
|
|
|
|
assert main(["close-outbox", "status"]) == 1
|
|
payload = json.loads(capsys.readouterr().out)
|
|
assert payload == {"delivered": 0, "pending": 1, "quarantined": 0}
|
|
|
|
|
|
def test_close_outbox_replay_delivers_pending_entry(
|
|
tmp_path: Path,
|
|
capsys,
|
|
monkeypatch,
|
|
) -> None:
|
|
outbox = CloseOutbox(state_dir=tmp_path / "runtime-state")
|
|
outbox.enqueue(
|
|
CloseRequest(
|
|
run_id="run-1",
|
|
transaction_id="tx-1",
|
|
worker_id="worker-1",
|
|
action="complete",
|
|
result={"ok": True},
|
|
)
|
|
)
|
|
|
|
class Client:
|
|
class Config:
|
|
worker_id = "worker-1"
|
|
|
|
config = Config()
|
|
|
|
def complete(self, run_id: str, *, result: dict):
|
|
assert run_id == "run-1"
|
|
assert result == {"ok": True}
|
|
return None
|
|
|
|
monkeypatch.setattr(
|
|
"rein_aharness.ops_run_client.ActivityCoreOpsClient",
|
|
Client,
|
|
)
|
|
|
|
assert main(["close-outbox", "replay"]) == 0
|
|
payload = json.loads(capsys.readouterr().out)
|
|
assert payload["delivered"] == 1
|
|
assert payload["pending"] == 0
|
|
|
|
|
|
def test_close_outbox_replay_rejects_invalid_limit(capsys) -> None:
|
|
assert main(["close-outbox", "replay", "--limit", "0"]) == 2
|
|
assert "between 1 and 1000" in capsys.readouterr().err
|