27 lines
783 B
Python
27 lines
783 B
Python
"""Integration tests for liveness/readiness (section 24). Requires
|
|||
|
|
PostgreSQL and Redis — see tests/conftest.py."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
from httpx import AsyncClient
|
||
|
|
|
||
|
|
pytestmark = pytest.mark.usefixtures("db_session")
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.asyncio
|
||
|
|
async def test_health_is_always_ok(client: AsyncClient):
|
||
|
|
response = await client.get("/health")
|
||
|
|
assert response.status_code == 200
|
||
|
|
assert response.json() == {"status": "ok"}
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.asyncio
|
||
|
|
async def test_ready_reports_postgresql_dependency(client: AsyncClient):
|
||
|
|
response = await client.get("/ready")
|
||
|
|
assert response.status_code == 200
|
||
|
|
body = response.json()
|
||
|
|
names = {dep["name"] for dep in body["dependencies"]}
|
||
|
|
assert "postgresql" in names
|
||
|
|
assert "redis" in names
|