30 lines
847 B
Python
30 lines
847 B
Python
from fastapi.testclient import TestClient
|
|
|
|
from yuqei_contract_api.config import ContractApiSettings
|
|
from yuqei_contract_api.main import create_app
|
|
|
|
|
|
def test_health_endpoint_returns_contract_api_status() -> None:
|
|
app = create_app(ContractApiSettings(environment="test"))
|
|
client = TestClient(app)
|
|
|
|
response = client.get("/health")
|
|
|
|
assert response.status_code == 200
|
|
assert response.json() == {
|
|
"status": "ok",
|
|
"service": "contract-api",
|
|
"version": "0.1.0",
|
|
"environment": "test",
|
|
}
|
|
|
|
|
|
def test_versioned_health_endpoint_matches_contract_api_prefix() -> None:
|
|
app = create_app(ContractApiSettings(environment="test"))
|
|
client = TestClient(app)
|
|
|
|
response = client.get("/api/v1/health")
|
|
|
|
assert response.status_code == 200
|
|
assert response.json()["service"] == "contract-api"
|