feat: add user model and registration endpoint
This commit is contained in:
21
backend/tests/test_auth.py
Normal file
21
backend/tests/test_auth.py
Normal 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
|
||||
Reference in New Issue
Block a user