-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e2ebca
commit af2cad7
Showing
3 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
|
||
from flask import json | ||
|
||
|
||
def test_register_success(client): | ||
"""Test successful user registration.""" | ||
response = client.post( | ||
"/api/auth/register", | ||
json={ | ||
"username": "newuser", | ||
"email": "[email protected]", | ||
"password": "TestPass123!", | ||
}, | ||
) | ||
assert response.status_code == 201 | ||
data = json.loads(response.data) | ||
assert "user" in data | ||
assert data["user"]["username"] == "newuser" | ||
assert data["user"]["email"] == "[email protected]" | ||
with patch("app.routes.auth.send_verification_email") as mock_email: | ||
mock_email.return_value = True | ||
|
||
response = client.post( | ||
"/api/auth/register", | ||
json={ | ||
"username": "newuser", | ||
"email": "[email protected]", | ||
"password": "TestPass123!", | ||
}, | ||
) | ||
assert response.status_code == 201 | ||
data = json.loads(response.data) | ||
assert "user" in data | ||
assert data["user"]["username"] == "newuser" | ||
assert data["user"]["email"] == "[email protected]" | ||
assert not data["user"]["email_verified"] | ||
|
||
|
||
def test_register_duplicate_username(client, test_user): | ||
|
@@ -70,7 +75,7 @@ def test_login_success(client, test_user): | |
"/api/auth/login", | ||
json={ | ||
"username": test_user.username, | ||
"password": "Test123!", # Must match the password set in test_user fixture | ||
"password": "Test123!", | ||
}, | ||
) | ||
assert response.status_code == 200 | ||
|