feat(tests): Add test configuration and helpers
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-08-23 22:17:53 +01:00
parent 3e04433272
commit 9e815b0619
7 changed files with 71 additions and 45 deletions

View File

@@ -1,25 +1,12 @@
import pytest
from httpx import AsyncClient, ASGITransport
# Импортируем наше главное FastAPI приложение
from app.main import app
# Тесты теперь не знают про 'app', они знают только про 'client'
@pytest.mark.asyncio
async def test_health_check():
"""
Тестирует эндпоинт проверки работоспособности (health check).
"""
# Создаем "транспорт", который работает с нашим app,
# и передаем его в AsyncClient.
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as client:
async def test_health_check(client): # <-- Получаем client как аргумент
response = await client.get("/")
# Отправляем асинхронный GET-запрос на корневой URL ("/")
response = await client.get("/")
# Проверки остаются без изменений
assert response.status_code == 200
assert response.json() == {
"status": "ok",
"message": "Welcome to Marquiz Metrica Connector!"
}
assert response.status_code == 200
assert response.json() == {
"status": "ok",
"message": "Welcome to Marquiz Metrica Connector!"
}