-
Notifications
You must be signed in to change notification settings - Fork 987
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sending emails: handle case where we want to email confirming account…
… deletion (#13396)
- Loading branch information
Showing
2 changed files
with
21 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,7 +288,8 @@ def test_sends_unverified_with_override( | |
|
||
|
||
class TestSendEmail: | ||
def test_send_email_success(self, db_session, monkeypatch): | ||
@pytest.mark.parametrize("delete_user", [True, False]) | ||
def test_send_email_success(self, delete_user, db_session, monkeypatch): | ||
class FakeMailSender: | ||
def __init__(self): | ||
self.emails = [] | ||
|
@@ -321,6 +322,8 @@ def __init__(self): | |
self.user = FakeUser() | ||
|
||
def get_user(self, user_id): | ||
if delete_user: | ||
return None | ||
return self.user | ||
|
||
user_service = FakeUserEventService() | ||
|
@@ -373,18 +376,21 @@ def get_user(self, user_id): | |
"recipient": "recipient", | ||
} | ||
] | ||
assert user_service.user.events == [ | ||
{ | ||
"tag": "account:email:sent", | ||
"ip_address": request.remote_addr, | ||
"additional": { | ||
"from_": "[email protected]", | ||
"to": "recipient", | ||
"subject": msg.subject, | ||
"redact_ip": False, | ||
}, | ||
} | ||
] | ||
if delete_user: | ||
assert user_service.user.events == [] | ||
else: | ||
assert user_service.user.events == [ | ||
{ | ||
"tag": "account:email:sent", | ||
"ip_address": request.remote_addr, | ||
"additional": { | ||
"from_": "[email protected]", | ||
"to": "recipient", | ||
"subject": msg.subject, | ||
"redact_ip": False, | ||
}, | ||
} | ||
] | ||
|
||
def test_send_email_failure_retry(self, monkeypatch): | ||
exc = Exception() | ||
|
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