Refactoring code for modular approach
This commit is contained in:
@@ -23,7 +23,7 @@ class TestAuthenticationAPI:
|
||||
def test_register_user_duplicate_email(self, client, test_user):
|
||||
"""Test registration with duplicate email"""
|
||||
response = client.post("/api/v1/auth/register", json={
|
||||
"email": "test@example.com", # Same as test_user
|
||||
"email": test_user.email, # Same as test_user
|
||||
"username": "newuser",
|
||||
"password": "securepass123"
|
||||
})
|
||||
@@ -35,7 +35,7 @@ class TestAuthenticationAPI:
|
||||
"""Test registration with duplicate username"""
|
||||
response = client.post("/api/v1/auth/register", json={
|
||||
"email": "new@example.com",
|
||||
"username": "testuser", # Same as test_user
|
||||
"username": test_user.username, # Same as test_user
|
||||
"password": "securepass123"
|
||||
})
|
||||
|
||||
@@ -45,7 +45,7 @@ class TestAuthenticationAPI:
|
||||
def test_login_success(self, client, test_user):
|
||||
"""Test successful login"""
|
||||
response = client.post("/api/v1/auth/login", json={
|
||||
"username": "testuser",
|
||||
"username": test_user.username,
|
||||
"password": "testpass123"
|
||||
})
|
||||
|
||||
@@ -54,7 +54,7 @@ class TestAuthenticationAPI:
|
||||
assert "access_token" in data
|
||||
assert data["token_type"] == "bearer"
|
||||
assert "expires_in" in data
|
||||
assert data["user"]["username"] == "testuser"
|
||||
assert data["user"]["username"] == test_user.username
|
||||
|
||||
def test_login_wrong_password(self, client, test_user):
|
||||
"""Test login with wrong password"""
|
||||
@@ -75,14 +75,14 @@ class TestAuthenticationAPI:
|
||||
|
||||
assert response.status_code == 401
|
||||
|
||||
def test_get_current_user_info(self, client, auth_headers):
|
||||
def test_get_current_user_info(self, client, auth_headers, test_user):
|
||||
"""Test getting current user info"""
|
||||
response = client.get("/api/v1/auth/me", headers=auth_headers)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["username"] == "testuser"
|
||||
assert data["email"] == "test@example.com"
|
||||
assert data["username"] == test_user.username
|
||||
assert data["email"] == test_user.email
|
||||
|
||||
def test_get_current_user_no_auth(self, client):
|
||||
"""Test getting current user without authentication"""
|
||||
|
||||
Reference in New Issue
Block a user