20 lines
565 B
Python
20 lines
565 B
Python
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
|