import pytest from httpx import AsyncClient, ASGITransport from app.main import app @pytest.mark.asyncio async def test_analyze_endpoint(): transport = ASGITransport(app=app) async with AsyncClient(transport=transport, base_url="http://test") as client: resp = await client.post("/api/v1/analyze", json={ "report_id": 1, "user_id": 1, "focus": "overall", }) assert resp.status_code == 200 data = resp.json() assert "analysis" in data @pytest.mark.asyncio async def test_analyze_missing_report(): transport = ASGITransport(app=app) async with AsyncClient(transport=transport, base_url="http://test") as client: resp = await client.post("/api/v1/analyze", json={ "report_id": -1, "user_id": 1, }) assert resp.status_code == 200 data = resp.json() assert isinstance(data.get("analysis"), str)