state-hub/tests/test_push_deadline.py
tegwick 7183f5993a fix: wait for bounded receive scanning during sync pushes
Assistant: codex
Assistant-Model: gpt-6-astra
Assistant-Session: 01a1346b-72a4-7d40-b8bd-8b8ca346cfa2
2026-10-13 16:04:41 +02:00

37 lines
1.2 KiB
Python

"""Client deadlines must accommodate receive scanning without claiming timeout refusal."""
import subprocess
from pathlib import Path
import sys
sys.path.insert(0, str(Path(__file__).parent.parent / "scripts"))
import repo_sync as module
def test_push_budget_covers_admitted_scanner(monkeypatch, tmp_path):
observed = {}
def run(argv, **kwargs):
observed.update(argv=argv, **kwargs)
return subprocess.CompletedProcess(argv, 0, "", "")
monkeypatch.setattr(module.subprocess, "run", run)
ok, _ = module.push_ff(tmp_path)
assert ok
assert 90 < observed["timeout"] <= 180
assert "--force" not in observed["argv"]
def test_timeout_is_unverified_without_retry_or_child_output(monkeypatch, tmp_path):
calls = []
def run(argv, **kwargs):
calls.append(argv)
raise subprocess.TimeoutExpired(argv, kwargs["timeout"], output="private diagnostic fixture")
monkeypatch.setattr(module.subprocess, "run", run)
ok, message = module.push_ff(tmp_path)
assert not ok
assert "remote outcome unverified" in message
assert "inspect the remote ref" in message
assert "private diagnostic fixture" not in message
assert len(calls) == 1