Files
zhuangxiu/services/api/tests/test_api.py
T

28 lines
874 B
Python

import httpx
import pytest
from app.main import app
@pytest.fixture
def transport() -> httpx.ASGITransport:
return httpx.ASGITransport(app=app)
@pytest.mark.asyncio
async def test_health(transport: httpx.ASGITransport) -> None:
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
response = await client.get("/v1/health")
assert response.status_code == 200
assert response.json()["status"] == "ok"
@pytest.mark.asyncio
async def test_demo_project_contract(transport: httpx.ASGITransport) -> None:
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
response = await client.get("/v1/projects/demo-apartment")
assert response.status_code == 200
body = response.json()
assert body["stage"] == "plan_review"
assert body["plan"]["cad_layer_count"] == 43