Skip to content

Commit ae55b7d

Browse files
committed
test: stabilize app-server status checks
1 parent 5ac3fed commit ae55b7d

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

tests/test_session_reflection_app_server.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import pytest
1414

15+
from codex_self_evolution.session_reflection import app_server as app_server_module
1516
from codex_self_evolution.session_reflection.app_server import (
1617
AppServerError,
1718
ReflectionAppServerClient,
@@ -288,6 +289,7 @@ def test_app_server_proxy_status_reports_missing_control_socket(
288289
) -> None:
289290
"""Proxy status reports why the default app-server control socket is unusable."""
290291
monkeypatch.setenv("CODEX_HOME", str(tmp_path / "codex-home"))
292+
monkeypatch.setattr(app_server_module.shutil, "which", lambda name: "/usr/bin/codex" if name == "codex" else None)
291293

292294
status = app_server_proxy_status()
293295

@@ -299,6 +301,24 @@ def test_app_server_proxy_status_reports_missing_control_socket(
299301
}
300302

301303

304+
def test_app_server_proxy_status_reports_missing_codex_binary(
305+
monkeypatch: pytest.MonkeyPatch,
306+
tmp_path: Path,
307+
) -> None:
308+
"""Proxy status fails loudly when neither a socket nor Codex binary exists."""
309+
monkeypatch.setenv("CODEX_HOME", str(tmp_path / "codex-home"))
310+
monkeypatch.setattr(app_server_module.shutil, "which", lambda name: None)
311+
312+
status = app_server_proxy_status()
313+
314+
assert status == {
315+
"available": False,
316+
"mode": None,
317+
"reason": "codex_binary_missing",
318+
"socket_path": str(tmp_path / "codex-home" / "app-server-control" / "app-server-control.sock"),
319+
}
320+
321+
302322
def test_app_server_proxy_status_accepts_existing_control_socket(
303323
monkeypatch: pytest.MonkeyPatch,
304324
) -> None:

tests/test_session_reflection_runner.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,15 @@ def test_session_reflection_status_is_compact(monkeypatch: pytest.MonkeyPatch, t
769769
repo = tmp_path / "repo"
770770
repo.mkdir()
771771
monkeypatch.setenv("CODEX_SELF_EVOLUTION_HOME", str(home))
772+
monkeypatch.setattr(
773+
"codex_self_evolution.session_reflection.runner.app_server_proxy_status",
774+
lambda: {
775+
"available": True,
776+
"mode": "managed_app_server",
777+
"reason": "control_socket_missing",
778+
"socket_path": str(tmp_path / "missing.sock"),
779+
},
780+
)
772781
job = create_job_from_payload(_payload(repo), home=home)
773782

774783
status = session_reflection_status(home=home)

0 commit comments

Comments
 (0)