test auth api

This commit is contained in:
IluaAir
2025-08-18 18:26:45 +03:00
parent eb5a1b9d85
commit cc3aad5c20
4 changed files with 56 additions and 23 deletions

View File

@@ -0,0 +1,29 @@
from httpx import AsyncClient
from src.core.settings import settings
from src.schemas.users import User
async def test_registration(ac):
user = {"username": "kot", "email": "super@kot.ru", "password": "P@ssw0rd"}
result = await ac.post(
f"{settings.api.v1_login_url}/signup",
json=user,
)
assert result.status_code == 200
assert User.model_validate(result.json())
assert result.json()["is_active"]
async def test_login(ac: AsyncClient):
result = await ac.post(
f"{settings.api.v1_login_url}/login",
data={
"grant_type": "password",
"username": "kot",
"password": "P@ssw0rd",
},
)
assert result.status_code == 200
assert result.json().get("access_token")