Skip to content

Commit 3ed93e1

Browse files
author
Harmanpreet Kaur
committed
added app_test file
1 parent 3458977 commit 3ed93e1

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

src/tests/backend/app_test.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from backend.app import create_app
2+
3+
from fastapi import FastAPI
4+
5+
from httpx import ASGITransport
6+
from httpx import AsyncClient
7+
8+
import pytest
9+
10+
11+
@pytest.fixture
12+
def app() -> FastAPI:
13+
"""Fixture to create a test app instance."""
14+
return create_app()
15+
16+
17+
@pytest.mark.asyncio
18+
async def test_health_check(app: FastAPI):
19+
"""Test the /health endpoint returns a healthy status."""
20+
transport = ASGITransport(app=app)
21+
async with AsyncClient(transport=transport, base_url="http://test") as ac:
22+
response = await ac.get("/health")
23+
assert response.status_code == 200
24+
assert response.json() == {"status": "healthy"}
25+
26+
27+
@pytest.mark.asyncio
28+
async def test_backend_routes_exist(app: FastAPI):
29+
"""Ensure /api routes are available (smoke test)."""
30+
# Check available routes include /api prefix from backend_router
31+
routes = [route.path for route in app.router.routes]
32+
backend_routes = [r for r in routes if r.startswith("/api")]
33+
assert backend_routes, "No backend routes found under /api prefix"

0 commit comments

Comments
 (0)