first commit
This commit is contained in:
19
tests/test_auth.py
Normal file
19
tests/test_auth.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from app.main import app
|
||||
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_register_and_me():
|
||||
email = "tester@example.com"
|
||||
password = "password123"
|
||||
r = client.post("/auth/register", json={"email": email, "password": password})
|
||||
assert r.status_code == 200
|
||||
tokens = r.json()
|
||||
assert "access_token" in tokens
|
||||
headers = {"Authorization": f"Bearer {tokens['access_token']}"}
|
||||
r2 = client.get("/users/me", headers=headers)
|
||||
assert r2.status_code == 200
|
||||
data = r2.json()
|
||||
assert data["email"] == email
|
||||
Reference in New Issue
Block a user