test_observability.py•1 kB
from __future__ import annotations
import httpx
import pytest
from uniprot_mcp.http_app import app
@pytest.mark.asyncio
async def test_health_includes_request_id_header():
transport = httpx.ASGITransport(app=app)
async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
response = await client.get("/healthz")
assert response.status_code == 200
request_id = response.headers.get("X-Request-Id")
assert request_id
assert len(request_id) >= 8
@pytest.mark.asyncio
async def test_metrics_endpoint_behaviour():
transport = httpx.ASGITransport(app=app)
async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
response = await client.get("/metrics")
if response.status_code == 200:
body = response.text
assert "python_info" in body or "process_start_time_seconds" in body
else:
assert response.status_code in {404, 405}