Initial clean commit of the project

This commit is contained in:
2025-08-23 21:47:21 +01:00
commit 0ef448008a
31 changed files with 1455 additions and 0 deletions

0
tests/__init__.py Normal file
View File

16
tests/test_counters.py Normal file
View File

@@ -0,0 +1,16 @@
import pytest
from httpx import AsyncClient, ASGITransport
from app.main import app
@pytest.mark.asyncio
async def test_get_counters_unauthorized():
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as client:
response = await client.get("/api/v1/counters/")
# Ожидаем 403, а не 401
assert response.status_code == 403
# Тело ответа для этой ошибки от HTTPBearer
assert response.json() == {"detail": "Not authenticated"}

25
tests/test_main.py Normal file
View File

@@ -0,0 +1,25 @@
import pytest
from httpx import AsyncClient, ASGITransport
# Импортируем наше главное FastAPI приложение
from app.main import app
@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:
# Отправляем асинхронный GET-запрос на корневой URL ("/")
response = await client.get("/")
# Проверки остаются без изменений
assert response.status_code == 200
assert response.json() == {
"status": "ok",
"message": "Welcome to Marquiz Metrica Connector!"
}