feat(tests): Add test configuration and helpers
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1,16 +1,8 @@
|
||||
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/")
|
||||
async def test_get_counters_unauthorized(client): # <-- Получаем client как аргумент
|
||||
response = await client.get("/api/v1/counters/")
|
||||
|
||||
# Ожидаем 403, а не 401
|
||||
assert response.status_code == 403
|
||||
|
||||
# Тело ответа для этой ошибки от HTTPBearer
|
||||
assert response.json() == {"detail": "Not authenticated"}
|
||||
assert response.status_code == 403
|
||||
assert response.json() == {"detail": "Not authenticated"}
|
||||
Reference in New Issue
Block a user