Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

test: give the Claude CLI path tests pids no process can hold (#2792)

Call Whitef4964e564c81
diff --git a/tests/test_claude_cli_path.py b/tests/test_claude_cli_path.py
index b5c66674d..5b7f933d9 100644
--- a/tests/test_claude_cli_path.py
+++ b/tests/test_claude_cli_path.py
@@ -41,6 +41,7 @@ from core.handlers.model_hub.service import ModelHubError
from modules.claude_sdk_compat import CLAUDE_SDK_MAX_BUFFER_SIZE
from modules.im import MessageContext
from tests import hang_guard
+from tests.fake_pid_helpers import fake_pid
from tests.scenario_harness.model_hub import (
UNLISTED_MODEL,
unlisted_model_copy,
@@ -1094,7 +1095,7 @@ def test_session_handler_moves_claude_process_into_agent_cgroup(monkeypatch, tmp
class _StubClaudeSDKClient:
def __init__(self, options):
- self._transport = type("Transport", (), {"_process": type("Process", (), {"pid": 9753})()})()
+ self._transport = type("Transport", (), {"_process": type("Process", (), {"pid": fake_pid(2)})()})()
async def connect(self) -> None:
return None
@@ -1117,7 +1118,7 @@ def test_session_handler_moves_claude_process_into_agent_cgroup(monkeypatch, tmp
_run_session(handler, MessageContext(user_id="U123", channel_id="C123"))
- assert calls == [(9753, "claude")]
+ assert calls == [(fake_pid(2), "claude")]
def test_session_handler_keeps_sdk_default_for_default_claude_binary(monkeypatch, tmp_path: Path) -> None:
@@ -1662,7 +1663,7 @@ def test_session_handler_marks_claude_sdk_session_process_owner(monkeypatch, tmp
class _StubClaudeSDKClient:
def __init__(self, options):
captured["options"] = options
- self._transport = type("T", (), {"_process": type("P", (), {"pid": 4321})()})()
+ self._transport = type("T", (), {"_process": type("P", (), {"pid": fake_pid(1)})()})()
async def connect(self) -> None:
captured["connected"] = True
@@ -3317,7 +3318,7 @@ def test_reap_orphaned_sessions_disables_in_tree_sweep_when_create_in_flight(mon
return 0
monkeypatch.setattr(session_handler_module, "reap_orphaned_claude_processes", _fake_reap)
- monkeypatch.setattr(session_handler_module, "get_claude_client_pid", lambda client: 4321)
+ monkeypatch.setattr(session_handler_module, "get_claude_client_pid", lambda client: fake_pid(1))
controller = _Controller(tmp_path)
handler = SessionHandler(controller)
@@ -3336,7 +3337,7 @@ def test_reap_orphaned_sessions_enables_in_tree_sweep_when_owner_set_complete(mo
return 0
monkeypatch.setattr(session_handler_module, "reap_orphaned_claude_processes", _fake_reap)
- monkeypatch.setattr(session_handler_module, "get_claude_client_pid", lambda client: 4321)
+ monkeypatch.setattr(session_handler_module, "get_claude_client_pid", lambda client: fake_pid(1))
controller = _Controller(tmp_path)
handler = SessionHandler(controller)
@@ -3360,7 +3361,7 @@ def test_reap_orphaned_sessions_excludes_active_watch_process_roots(monkeypatch,
return {500}
monkeypatch.setattr(session_handler_module, "reap_orphaned_claude_processes", _fake_reap)
- monkeypatch.setattr(session_handler_module, "get_claude_client_pid", lambda client: 4321)
+ monkeypatch.setattr(session_handler_module, "get_claude_client_pid", lambda client: fake_pid(1))
controller = _Controller(tmp_path)
controller.watch_service = _WatchService()
@@ -3385,7 +3386,7 @@ def test_reap_orphaned_sessions_excludes_active_claude_auth_clients(monkeypatch,
return {600}
monkeypatch.setattr(session_handler_module, "reap_orphaned_claude_processes", _fake_reap)
- monkeypatch.setattr(session_handler_module, "get_claude_client_pid", lambda client: 4321)
+ monkeypatch.setattr(session_handler_module, "get_claude_client_pid", lambda client: fake_pid(1))
controller = _Controller(tmp_path)
controller.agent_auth_service = _AuthService()
@@ -3417,7 +3418,7 @@ def test_reap_orphaned_sessions_disables_in_tree_when_auth_client_pid_unknown(
return True
monkeypatch.setattr(session_handler_module, "reap_orphaned_claude_processes", _fake_reap)
- monkeypatch.setattr(session_handler_module, "get_claude_client_pid", lambda client: 4321)
+ monkeypatch.setattr(session_handler_module, "get_claude_client_pid", lambda client: fake_pid(1))
controller = _Controller(tmp_path)
controller.agent_auth_service = _AuthService()
@@ -3882,7 +3883,7 @@ def test_evict_idle_sessions_reaps_native_resume_processes(monkeypatch, tmp_path
self._transport = type(
"Transport",
(),
- {"_process": type("Process", (), {"pid": 4321})()},
+ {"_process": type("Process", (), {"pid": fake_pid(1)})()},
)()
captured["client"] = self
@@ -3947,7 +3948,7 @@ def test_cleanup_defers_duplicate_reap_while_a_client_create_is_in_flight(
self._transport = type(
"Transport",
(),
- {"_process": type("Process", (), {"pid": 4321})()},
+ {"_process": type("Process", (), {"pid": fake_pid(1)})()},
)()
async def connect(self) -> None:
@@ -3995,7 +3996,7 @@ def test_evict_idle_sessions_protects_pids_of_other_live_sessions(monkeypatch, t
self._transport = type(
"Transport",
(),
- {"_process": type("Process", (), {"pid": 4321})()},
+ {"_process": type("Process", (), {"pid": fake_pid(1)})()},
)()
async def connect(self) -> None:
@@ -4059,7 +4060,7 @@ def test_cleanup_defers_duplicate_reap_when_a_live_client_pid_is_unresolved(
self._transport = type(
"Transport",
(),
- {"_process": type("Process", (), {"pid": 4321})()},
+ {"_process": type("Process", (), {"pid": fake_pid(1)})()},
)()
async def connect(self) -> None:
@@ -4114,7 +4115,7 @@ def test_cleanup_skips_a_generation_a_replacement_already_took_over(
self._transport = type(
"Transport",
(),
- {"_process": type("Process", (), {"pid": 4321})()},
+ {"_process": type("Process", (), {"pid": fake_pid(1)})()},
)()
async def connect(self) -> None: