test(bot-relay): live-Bot-Chat deliver test ignores the server's import-time git prefetch

tui_gateway.server kicks off prefetch_update_check() at import, which runs
`git rev-parse`/`rev-list` on a daemon thread. The test patched
subprocess.run with a fake that returned None and recorded every call, so
whenever that thread landed inside the test window the assertion saw a
`git` argv and the thread crashed on `.returncode` (red on main since
6e775907d7 made the fetch slower). Filter to non-git spawns and return a
real-shaped proc for everything.
This commit is contained in:
Teknium
2026-09-02 21:15:00 -07:00
parent 116ca1db1e
commit a2a16dfdac
+12 -5
View File
@@ -116,7 +116,18 @@ def test_deliver_lands_in_live_bot_chat_instead_of_subprocess(home, monkeypatch)
"""
spawned = []
submitted = []
monkeypatch.setattr("subprocess.run", lambda *a, **k: spawned.append(a) or None)
class _Proc:
returncode, stdout, stderr = 0, "pong", ""
def _fake_run(argv, *a, **k):
# The server module's import-time update prefetch runs `git ...` on a
# daemon thread; only the relay's `hermes` CLI spawn is under test.
if argv and argv[0] != "git":
spawned.append(argv)
return _Proc()
monkeypatch.setattr("subprocess.run", _fake_run)
monkeypatch.setitem(
srv._methods, "prompt.submit", lambda rid, p: submitted.append(p) or srv._ok(rid, {"status": "streaming"})
)
@@ -137,10 +148,6 @@ def test_deliver_lands_in_live_bot_chat_instead_of_subprocess(home, monkeypatch)
srv._sessions["live-ops"]["pending_title"] = "Scratch"
submitted.clear()
class _Proc:
returncode, stdout, stderr = 0, "pong", ""
monkeypatch.setattr("subprocess.run", lambda *a, **k: spawned.append(a) or _Proc())
out = _result(srv._methods["bot_relay.deliver"](2, {"profile": "ops", "message": "ping"}))
assert out["reply"] == "pong" and spawned and not submitted