feat: add user model and registration endpoint

This commit is contained in:
Indiana
2026-07-20 15:14:31 +00:00
parent 9e69c622c9
commit cfffc7ff59
9 changed files with 147 additions and 7 deletions

View File

@@ -0,0 +1,21 @@
import pytest
@pytest.mark.asyncio
async def test_register_creates_user(client):
response = await client.post(
"/auth/register",
json={"username": "medium1", "password": "spookyspooky"},
)
assert response.status_code == 201
body = response.json()
assert body["username"] == "medium1"
assert "id" in body
assert "password" not in body
@pytest.mark.asyncio
async def test_register_duplicate_username_rejected(client):
await client.post("/auth/register", json={"username": "medium1", "password": "spookyspooky"})
response = await client.post("/auth/register", json={"username": "medium1", "password": "anotherpass"})
assert response.status_code == 409