feat: publish CodexPi contest snapshot
Some checks are pending
Qualité / tests (push) Waiting to run
Some checks are pending
Qualité / tests (push) Waiting to run
This commit is contained in:
32
tests/test_agent_service.py
Normal file
32
tests/test_agent_service.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import asyncio
|
||||
|
||||
from codexpi import agent_service
|
||||
from codexpi.commands import CommandResult
|
||||
|
||||
|
||||
def test_agent_accounts_status_detects_connections(monkeypatch):
|
||||
monkeypatch.setattr(agent_service.shutil, "which", lambda binary: f"/usr/bin/{binary}")
|
||||
|
||||
async def fake_run(argv, **_kwargs):
|
||||
binary = argv[0].rsplit("/", 1)[-1]
|
||||
if binary == "codex":
|
||||
return CommandResult(argv, 0, "Logged in using ChatGPT\n", "")
|
||||
if binary == "claude":
|
||||
return CommandResult(argv, 0, '{"loggedIn":false}', "")
|
||||
return CommandResult(argv, 0, "0 credentials", "")
|
||||
|
||||
monkeypatch.setattr(agent_service, "run_command", fake_run)
|
||||
rows = asyncio.run(agent_service.agent_accounts_status("codex", "claude", "opencode"))
|
||||
|
||||
assert [row["id"] for row in rows] == ["codex", "claude", "opencode"]
|
||||
assert rows[0]["connected"] is True
|
||||
assert rows[0]["account"] == "Logged in using ChatGPT"
|
||||
assert rows[1]["connected"] is False
|
||||
assert rows[2]["connected"] is False
|
||||
|
||||
|
||||
def test_agent_accounts_status_reports_missing_binary(monkeypatch):
|
||||
monkeypatch.setattr(agent_service.shutil, "which", lambda _binary: None)
|
||||
rows = asyncio.run(agent_service.agent_accounts_status("codex", "claude", "opencode"))
|
||||
assert all(row["installed"] is False for row in rows)
|
||||
assert rows[1]["command"] == "claude auth login"
|
||||
Reference in New Issue
Block a user