40 lines
986 B
Python
40 lines
986 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from fastapi.testclient import TestClient
|
||
|
|
|
||
|
|
from app import app
|
||
|
|
|
||
|
|
|
||
|
|
def test_app_health_returns_envelope() -> None:
|
||
|
|
client = TestClient(app)
|
||
|
|
|
||
|
|
response = client.get("/health")
|
||
|
|
|
||
|
|
assert response.status_code == 200
|
||
|
|
body = response.json()
|
||
|
|
assert body["status"] == "ok"
|
||
|
|
|
||
|
|
|
||
|
|
def test_mobile_router_health_returns_envelope() -> None:
|
||
|
|
client = TestClient(app)
|
||
|
|
|
||
|
|
response = client.get("/api/v1/health")
|
||
|
|
|
||
|
|
assert response.status_code == 200
|
||
|
|
body = response.json()
|
||
|
|
assert body["status"] == "ok"
|
||
|
|
|
||
|
|
|
||
|
|
def test_not_found_returns_error_envelope() -> None:
|
||
|
|
client = TestClient(app)
|
||
|
|
|
||
|
|
response = client.get("/missing-route")
|
||
|
|
|
||
|
|
assert response.status_code == 404
|
||
|
|
assert response.headers["content-type"].startswith("application/problem+json")
|
||
|
|
body = response.json()
|
||
|
|
assert body["type"] == "about:blank"
|
||
|
|
assert body["title"] == "Not Found"
|
||
|
|
assert body["status"] == 404
|
||
|
|
assert body["detail"] == "Not Found"
|