from __future__ import annotations
from fastapi.testclient import TestClient
from app.main import app
class DummyAgent:
async def run(self, query: str):
return {
"response": f"ok: {query}",
"action": "dummy_action",
"tool_result": {"echo": query},
}
def test_query_endpoint_returns_agent_response():
with TestClient(app) as client:
app.state.agent = DummyAgent()
response = client.post(
"/api/v1/agent/query",
json={"query": "Покажи продукты"},
)
assert response.status_code == 200
payload = response.json()
assert payload["action"] == "dummy_action"
assert payload["response"] == "ok: Покажи продукты"