Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

email_notifications: Complete test coverage for module.

Adam Sahc6130ce4b10f
diff --git a/tools/test-backend b/tools/test-backend
index a670765c1a6..a466c5258d4 100755
--- a/tools/test-backend
+++ b/tools/test-backend
@@ -79,7 +79,6 @@ not_yet_fully_covered = [
"zerver/lib/cache.py",
"zerver/lib/cache_helpers.py",
"zerver/lib/i18n.py",
- "zerver/lib/email_notifications.py",
"zerver/lib/send_email.py",
"zerver/lib/url_preview/preview.py",
"zerver/worker/queue_processors.py",
diff --git a/zerver/tests/test_email_notifications.py b/zerver/tests/test_email_notifications.py
index b2c712e2cdc..342b964a75c 100644
--- a/zerver/tests/test_email_notifications.py
+++ b/zerver/tests/test_email_notifications.py
@@ -1526,3 +1526,22 @@ class TestFollowupEmailDelay(ZulipTestCase):
# Test date_joined == Friday
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))
+
+
+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)