22 lines
709 B
Python
22 lines
709 B
Python
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
|