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.

refactor: Move receives_email_notifications tests to designated file.

Abhijeet Prasad Bodas44534ca47ebe
diff --git a/zerver/tests/test_email_notifications.py b/zerver/tests/test_email_notifications.py
index 83979ee652b..0cf2c8bb07d 100644
--- a/zerver/tests/test_email_notifications.py
+++ b/zerver/tests/test_email_notifications.py
@@ -21,7 +21,13 @@ from zerver.lib.email_notifications import (
)
from zerver.lib.send_email import FromAddress, send_custom_email
from zerver.lib.test_classes import ZulipTestCase
-from zerver.models import ScheduledEmail, UserProfile, get_realm, get_stream
+from zerver.models import (
+ ScheduledEmail,
+ UserProfile,
+ get_realm,
+ get_stream,
+ receives_offline_email_notifications,
+)
class TestCustomEmails(ZulipTestCase):
@@ -1212,3 +1218,37 @@ class TestMissedMessages(ZulipTestCase):
+ 'title="cloud with lightning and rain" style="height: 20px;">.</p>'
)
self.assertEqual(actual_output, expected_output)
+
+
+class TestReceivesNotificationsFunctions(ZulipTestCase):
+ def test_receivers_offline_notifications_when_user_is_a_bot(self) -> None:
+ hamlet = self.example_user("hamlet")
+ hamlet.is_bot = True
+
+ hamlet.enable_offline_email_notifications = True
+ self.assertFalse(receives_offline_email_notifications(hamlet))
+
+ hamlet.enable_offline_email_notifications = False
+ self.assertFalse(receives_offline_email_notifications(hamlet))
+
+ hamlet.enable_offline_email_notifications = True
+ self.assertFalse(receives_offline_email_notifications(hamlet))
+
+ hamlet.enable_offline_email_notifications = False
+ self.assertFalse(receives_offline_email_notifications(hamlet))
+
+ def test_receivers_offline_notifications_when_user_is_not_a_bot(self) -> None:
+ hamlet = self.example_user("hamlet")
+ hamlet.is_bot = False
+
+ hamlet.enable_offline_email_notifications = True
+ self.assertTrue(receives_offline_email_notifications(hamlet))
+
+ hamlet.enable_offline_email_notifications = False
+ self.assertFalse(receives_offline_email_notifications(hamlet))
+
+ hamlet.enable_offline_email_notifications = True
+ self.assertTrue(receives_offline_email_notifications(hamlet))
+
+ hamlet.enable_offline_email_notifications = False
+ self.assertFalse(receives_offline_email_notifications(hamlet))
diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py
index eaca359e8ea..56a4c99139d 100644
--- a/zerver/tests/test_push_notifications.py
+++ b/zerver/tests/test_push_notifications.py
@@ -70,7 +70,6 @@ from zerver.models import (
get_client,
get_realm,
get_stream,
- receives_offline_email_notifications,
receives_offline_push_notifications,
receives_online_push_notifications,
)
@@ -2213,48 +2212,32 @@ class TestReceivesNotificationsFunctions(ZulipTestCase):
def test_receivers_offline_notifications_when_user_is_a_bot(self) -> None:
self.user.is_bot = True
- self.user.enable_offline_email_notifications = True
self.user.enable_offline_push_notifications = True
self.assertFalse(receives_offline_push_notifications(self.user))
- self.assertFalse(receives_offline_email_notifications(self.user))
- self.user.enable_offline_email_notifications = False
self.user.enable_offline_push_notifications = False
self.assertFalse(receives_offline_push_notifications(self.user))
- self.assertFalse(receives_offline_email_notifications(self.user))
- self.user.enable_offline_email_notifications = True
self.user.enable_offline_push_notifications = False
self.assertFalse(receives_offline_push_notifications(self.user))
- self.assertFalse(receives_offline_email_notifications(self.user))
- self.user.enable_offline_email_notifications = False
self.user.enable_offline_push_notifications = True
self.assertFalse(receives_offline_push_notifications(self.user))
- self.assertFalse(receives_offline_email_notifications(self.user))
def test_receivers_offline_notifications_when_user_is_not_a_bot(self) -> None:
self.user.is_bot = False
- self.user.enable_offline_email_notifications = True
self.user.enable_offline_push_notifications = True
self.assertTrue(receives_offline_push_notifications(self.user))
- self.assertTrue(receives_offline_email_notifications(self.user))
- self.user.enable_offline_email_notifications = False
self.user.enable_offline_push_notifications = False
self.assertFalse(receives_offline_push_notifications(self.user))
- self.assertFalse(receives_offline_email_notifications(self.user))
- self.user.enable_offline_email_notifications = True
self.user.enable_offline_push_notifications = False
self.assertFalse(receives_offline_push_notifications(self.user))
- self.assertTrue(receives_offline_email_notifications(self.user))
- self.user.enable_offline_email_notifications = False
self.user.enable_offline_push_notifications = True
self.assertTrue(receives_offline_push_notifications(self.user))
- self.assertFalse(receives_offline_email_notifications(self.user))
class TestPushNotificationsContent(ZulipTestCase):