Files
marquiz-metrics/tests/test_counters.py

16 lines
559 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"}