first commit
Some checks failed
CI / backend (push) Has been cancelled
CI / frontend (push) Has been cancelled

This commit is contained in:
2026-07-23 02:38:05 +03:00
commit 8757bec8ac
335 changed files with 61527 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
"""Тесты для 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