"""Auth API tests.""" import pytest from app import create_app, db from app.models.user import User @pytest.fixture def client(): app = create_app("testing") with app.test_client() as c: with app.app_context(): db.create_all() yield c db.drop_all() def test_register(client): r = client.post( "/api/v1/auth/register", json={"email": "test@example.com", "username": "testuser", "password": "secret123"}, ) assert r.status_code == 201 data = r.get_json() assert "access_token" in data assert data["user"]["email"] == "test@example.com" def test_login(client): client.post( "/api/v1/auth/register", json={"email": "login@example.com", "username": "loginuser", "password": "pass123"}, ) r = client.post( "/api/v1/auth/login", json={"email": "login@example.com", "password": "pass123"}, ) assert r.status_code == 200 assert "access_token" in r.get_json()