email_notifications: Complete test coverage for module.

Following the last commit, there was this WELCOME_EMAIL_SENDER code
without an existing automated test.
This commit is contained in:
Adam Sah 2022-08-02 08:16:49 +03:00 committed by Tim Abbott
parent d123056000
commit c6130ce4b1
2 changed files with 19 additions and 1 deletions

View File

@ -79,7 +79,6 @@ not_yet_fully_covered = [
"zerver/lib/cache.py", "zerver/lib/cache.py",
"zerver/lib/cache_helpers.py", "zerver/lib/cache_helpers.py",
"zerver/lib/i18n.py", "zerver/lib/i18n.py",
"zerver/lib/email_notifications.py",
"zerver/lib/send_email.py", "zerver/lib/send_email.py",
"zerver/lib/url_preview/preview.py", "zerver/lib/url_preview/preview.py",
"zerver/worker/queue_processors.py", "zerver/worker/queue_processors.py",

View File

@ -1526,3 +1526,22 @@ class TestFollowupEmailDelay(ZulipTestCase):
# Test date_joined == Friday # Test date_joined == Friday
user_profile.date_joined = datetime(2018, 1, 5, 1, 0, 0, 0, tzinfo=timezone.utc) user_profile.date_joined = datetime(2018, 1, 5, 1, 0, 0, 0, tzinfo=timezone.utc)
self.assertEqual(followup_day2_email_delay(user_profile), timedelta(days=3, hours=-1)) self.assertEqual(followup_day2_email_delay(user_profile), timedelta(days=3, hours=-1))
class TestCustomEmailSender(ZulipTestCase):
def test_custom_email_sender(self) -> None:
name = "Nonreg Email"
email = self.nonreg_email("test")
with override_settings(
WELCOME_EMAIL_SENDER={
"name": name,
"email": email,
}
):
hamlet = self.example_user("hamlet")
enqueue_welcome_emails(hamlet)
scheduled_emails = ScheduledEmail.objects.filter(users=hamlet)
email_data = orjson.loads(scheduled_emails[0].data)
self.assertEqual(email_data["context"]["email"], self.example_email("hamlet"))
self.assertEqual(email_data["from_name"], name)
self.assertEqual(email_data["from_address"], email)