Initialize uv-managed FastAPI backend

This commit is contained in:
2026-09-15 19:00:10 +08:00
commit fd30c83152
8 changed files with 482 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
from fastapi.testclient import TestClient
from backend_server.main import app
client = TestClient(app)
def test_health():
response = client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}
def test_local_frontend_cors():
response = client.get("/health", headers={"Origin": "http://localhost:5173"})
assert response.headers["access-control-allow-origin"] == "http://localhost:5173"
def test_unknown_origin_not_allowed():
response = client.get("/health", headers={"Origin": "https://unknown.example"})
assert "access-control-allow-origin" not in response.headers