ConfigManager V2
This commit is contained in:
41
tests/v2/test_health_endpoint.py
Normal file
41
tests/v2/test_health_endpoint.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import asyncio
|
||||
|
||||
from config_manager.v2.health import HealthServer
|
||||
|
||||
|
||||
def test_health_mapping_ok_to_200():
|
||||
async def provider():
|
||||
return {"status": "ok"}
|
||||
|
||||
async def scenario() -> None:
|
||||
server = HealthServer(
|
||||
host="127.0.0.1",
|
||||
port=8000,
|
||||
path="/health",
|
||||
timeout=0.2,
|
||||
health_provider=provider,
|
||||
)
|
||||
code, payload = await server._build_health_response()
|
||||
assert code == 200
|
||||
assert payload["status"] == "ok"
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def test_health_mapping_unhealthy_to_503():
|
||||
async def provider():
|
||||
return {"status": "unhealthy", "detail": "worker failed"}
|
||||
|
||||
async def scenario() -> None:
|
||||
server = HealthServer(
|
||||
host="127.0.0.1",
|
||||
port=8000,
|
||||
path="/health",
|
||||
timeout=0.2,
|
||||
health_provider=provider,
|
||||
)
|
||||
code, payload = await server._build_health_response()
|
||||
assert code == 503
|
||||
assert payload["status"] == "unhealthy"
|
||||
|
||||
asyncio.run(scenario())
|
||||
Reference in New Issue
Block a user