"""Тесты для GET /api/health.""" from collections.abc import AsyncGenerator from unittest.mock import AsyncMock, patch import httpx from httpx import ASGITransport from core.db import get_session from main import create_app class _FakeSession: async def execute(self, *args: object, **kwargs: object) -> None: return None async def _fake_get_session() -> AsyncGenerator[_FakeSession, None]: yield _FakeSession() async def test_health_ok() -> None: app = create_app() app.dependency_overrides[get_session] = _fake_get_session with patch("api.health.redis_client.ping", new=AsyncMock(return_value=True)): transport = ASGITransport(app=app) async with httpx.AsyncClient(transport=transport, base_url="http://test") as client: response = await client.get("/api/health") assert response.status_code == 200 body = response.json() assert body["status"] == "ok" assert body["db"] is True assert body["redis"] is True # Версия инстанса — значение из Settings, не фиксируем точную # строку здесь (совпадает с дефолтом Settings.vidconf_version в dev). assert "version" in body