import pytest from httpx import AsyncClient, ASGITransport from app.main import app @pytest.mark.asyncio async def test_chat_endpoint(): transport = ASGITransport(app=app) async with AsyncClient(transport=transport, base_url="http://test") as client: resp = await client.post("/api/v1/chat", json={ "query": "你好", "user_id": 1, "conversation_id": "", }) assert resp.status_code == 200 data = resp.json() assert "answer" in data assert isinstance(data.get("tasks"), list)