20 lines
726 B
Python
20 lines
726 B
Python
import pytest
|
|
from httpx import ASGITransport, AsyncClient
|
|
|
|
from app.core.database import init_db
|
|
from app.main import app
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_anonymous_login_returns_reusable_user_token():
|
|
await init_db()
|
|
transport = ASGITransport(app=app)
|
|
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
|
first = await client.post("/api/v1/auth/anonymous-login", json={"client_id": "browser-1"})
|
|
second = await client.post("/api/v1/auth/anonymous-login", json={"client_id": "browser-1"})
|
|
|
|
assert first.status_code == 200
|
|
assert second.status_code == 200
|
|
assert first.json()["user_id"] == second.json()["user_id"]
|
|
assert first.json()["access_token"]
|