diff --git a/agent-office/app/main.py b/agent-office/app/main.py index d275e14..608b6c6 100644 --- a/agent-office/app/main.py +++ b/agent-office/app/main.py @@ -187,6 +187,11 @@ async def telegram_webhook(data: dict): def all_states(): return {"agents": get_all_agent_states()} +@app.get("/api/agent-office/nodes") +async def nodes_status(): + from .node_monitor import collect_status + return await collect_status() + @app.get("/api/agent-office/agents/{agent_id}/token-usage") def agent_token_usage(agent_id: str, days: int = 1): from .db import get_token_usage_stats diff --git a/agent-office/tests/test_nodes_endpoint.py b/agent-office/tests/test_nodes_endpoint.py new file mode 100644 index 0000000..2ea82cd --- /dev/null +++ b/agent-office/tests/test_nodes_endpoint.py @@ -0,0 +1,18 @@ +# agent-office/tests/test_nodes_endpoint.py +import pytest +from fastapi.testclient import TestClient + +@pytest.fixture +def client(monkeypatch): + from app import main + async def fake_collect(redis=None): + return {"redis_ok": True, "paused": False, "paused_reason": None, + "generated_at": "2026-06-29T00:00:00Z", "workers": [], "links": []} + monkeypatch.setattr("app.node_monitor.collect_status", fake_collect) + return TestClient(main.app) + +def test_nodes_endpoint_returns_contract(client): + resp = client.get("/api/agent-office/nodes") + assert resp.status_code == 200 + body = resp.json() + assert set(["redis_ok","paused","workers","links"]).issubset(body)