Loading tests/ai_agent/test_error_codes.py +20 −2 Changes for tests/ai_agent/test_error_codes.py: 20 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -21,10 +21,13 @@ app = ai_agent_app.app async def _make_request(method: str, path: str, **kwargs: object) -> httpx.Response: transport = httpx.ASGITransport(app=app) async with httpx.AsyncClient(transport=transport, base_url="http://test") as client: async with httpx.AsyncClient( transport=transport, base_url="http://test", headers={"Authorization": "Bearer test-token"}, ) as client: return await client.request(method, path, **kwargs) def test_groq_query_missing_query_returns_400() -> None: response = asyncio.run(_make_request("POST", "/groq-mcp", json={})) Loading Loading @@ -55,3 +58,18 @@ def test_groq_query_agent_failure_returns_500() -> None: response = asyncio.run(_run()) assert response.status_code == 500 assert response.json() == {"error": "backend failure"} def test_groq_query_without_authorization_returns_401() -> None: async def _run() -> httpx.Response: transport = httpx.ASGITransport(app=app) async with httpx.AsyncClient( transport=transport, base_url="http://test" ) as client: return await client.post("/groq-mcp", json={"query": "hello"}) response = asyncio.run(_run()) assert response.status_code == 401 assert response.json() == {"detail": "Bearer token required"} assert response.headers["www-authenticate"] == "Bearer" No newline at end of file Loading
tests/ai_agent/test_error_codes.py +20 −2 Changes for tests/ai_agent/test_error_codes.py: 20 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -21,10 +21,13 @@ app = ai_agent_app.app async def _make_request(method: str, path: str, **kwargs: object) -> httpx.Response: transport = httpx.ASGITransport(app=app) async with httpx.AsyncClient(transport=transport, base_url="http://test") as client: async with httpx.AsyncClient( transport=transport, base_url="http://test", headers={"Authorization": "Bearer test-token"}, ) as client: return await client.request(method, path, **kwargs) def test_groq_query_missing_query_returns_400() -> None: response = asyncio.run(_make_request("POST", "/groq-mcp", json={})) Loading Loading @@ -55,3 +58,18 @@ def test_groq_query_agent_failure_returns_500() -> None: response = asyncio.run(_run()) assert response.status_code == 500 assert response.json() == {"error": "backend failure"} def test_groq_query_without_authorization_returns_401() -> None: async def _run() -> httpx.Response: transport = httpx.ASGITransport(app=app) async with httpx.AsyncClient( transport=transport, base_url="http://test" ) as client: return await client.post("/groq-mcp", json={"query": "hello"}) response = asyncio.run(_run()) assert response.status_code == 401 assert response.json() == {"detail": "Bearer token required"} assert response.headers["www-authenticate"] == "Bearer" No newline at end of file