import pytest from httpx import AsyncClient, ASGITransport from src.backend.config import settings @pytest.mark.anyio async def test_health_without_api_key(): """Request without API key should fail with 403 when key is configured.""" from src.backend.main import app transport = ASGITransport(app=app) async with AsyncClient(transport=transport, base_url="http://test") as ac: resp = await ac.get("/api/health") if settings.api_key: assert resp.status_code in (403, 422)