31 lines
811 B
Python
31 lines
811 B
Python
from fastapi.testclient import TestClient
|
|
from hypothesis import given, settings
|
|
from hypothesis import strategies as st
|
|
|
|
from main import app
|
|
|
|
client = TestClient(app)
|
|
|
|
|
|
def test_liveness_ok():
|
|
response = client.get("/healthz")
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["status"] == "ok"
|
|
assert data["service"] == "backend"
|
|
assert data["environment"]
|
|
|
|
|
|
def test_readiness_ok():
|
|
response = client.get("/readyz")
|
|
assert response.status_code == 200
|
|
assert response.json()["status"] == "ok"
|
|
|
|
|
|
@given(st.text(min_size=0, max_size=16))
|
|
@settings(max_examples=10)
|
|
def test_health_resilient_to_query_noise(noise: str):
|
|
resp = client.get("/healthz", params={"noise": noise})
|
|
assert resp.status_code == 200
|
|
assert resp.json()["status"] == "ok"
|