diff --git a/backend/app/api/health.py b/backend/app/api/health.py new file mode 100644 index 0000000..b992325 --- /dev/null +++ b/backend/app/api/health.py @@ -0,0 +1,8 @@ +from fastapi import APIRouter + +router = APIRouter() + + +@router.get("/health") +async def health(): + return {"status": "ok"} diff --git a/backend/app/api/media.py b/backend/app/api/media.py new file mode 100644 index 0000000..af9233c --- /dev/null +++ b/backend/app/api/media.py @@ -0,0 +1,3 @@ +from fastapi import APIRouter + +router = APIRouter() diff --git a/backend/app/main.py b/backend/app/main.py new file mode 100644 index 0000000..cf7a5ca --- /dev/null +++ b/backend/app/main.py @@ -0,0 +1,18 @@ +from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware +from app.api.health import router as health_router +from app.api.media import router as media_router +from app.core.config import settings + +app = FastAPI(title="HomeHub API", version="0.1.0") + +app.add_middleware( + CORSMiddleware, + allow_origins=settings.cors_origins_list, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + +app.include_router(health_router, prefix="/api") +app.include_router(media_router, prefix="/api/media") diff --git a/backend/tests/conftest.py b/backend/tests/conftest.py new file mode 100644 index 0000000..d062391 --- /dev/null +++ b/backend/tests/conftest.py @@ -0,0 +1,9 @@ +import pytest +from httpx import AsyncClient, ASGITransport +from app.main import app + + +@pytest.fixture +async def client(): + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: + yield ac diff --git a/backend/tests/test_health.py b/backend/tests/test_health.py new file mode 100644 index 0000000..4985e3d --- /dev/null +++ b/backend/tests/test_health.py @@ -0,0 +1,4 @@ +async def test_health_retourne_ok(client): + response = await client.get("/api/health") + assert response.status_code == 200 + assert response.json() == {"status": "ok"}