bugfix: The randomly generated email by Faker actually corresponded to an existing account in the test database, causing the test to fail. (#25646)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
db01cbb63d
commit
7a626747cf
1 changed files with 11 additions and 3 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
import time
|
||||||
|
import uuid
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
@ -248,9 +250,15 @@ class TestWebAppAuthService:
|
||||||
- Proper error handling for non-existent accounts
|
- Proper error handling for non-existent accounts
|
||||||
- Correct exception type and message
|
- Correct exception type and message
|
||||||
"""
|
"""
|
||||||
# Arrange: Use non-existent email
|
# Arrange: Generate a guaranteed non-existent email
|
||||||
fake = Faker()
|
# Use UUID and timestamp to ensure uniqueness
|
||||||
non_existent_email = fake.email()
|
unique_id = str(uuid.uuid4()).replace("-", "")
|
||||||
|
timestamp = str(int(time.time() * 1000000)) # microseconds
|
||||||
|
non_existent_email = f"nonexistent_{unique_id}_{timestamp}@test-domain-that-never-exists.invalid"
|
||||||
|
|
||||||
|
# Double-check this email doesn't exist in the database
|
||||||
|
existing_account = db_session_with_containers.query(Account).filter_by(email=non_existent_email).first()
|
||||||
|
assert existing_account is None, f"Test email {non_existent_email} already exists in database"
|
||||||
|
|
||||||
# Act & Assert: Verify proper error handling
|
# Act & Assert: Verify proper error handling
|
||||||
with pytest.raises(AccountNotFoundError):
|
with pytest.raises(AccountNotFoundError):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue