mirror of https://github.com/zulip/zulip.git
refactor: Move receives_email_notifications tests to designated file.
This commit is contained in:
parent
3990b183ce
commit
44534ca47e
|
@ -21,7 +21,13 @@ from zerver.lib.email_notifications import (
|
||||||
)
|
)
|
||||||
from zerver.lib.send_email import FromAddress, send_custom_email
|
from zerver.lib.send_email import FromAddress, send_custom_email
|
||||||
from zerver.lib.test_classes import ZulipTestCase
|
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):
|
class TestCustomEmails(ZulipTestCase):
|
||||||
|
@ -1212,3 +1218,37 @@ class TestMissedMessages(ZulipTestCase):
|
||||||
+ 'title="cloud with lightning and rain" style="height: 20px;">.</p>'
|
+ 'title="cloud with lightning and rain" style="height: 20px;">.</p>'
|
||||||
)
|
)
|
||||||
self.assertEqual(actual_output, expected_output)
|
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))
|
||||||
|
|
|
@ -70,7 +70,6 @@ from zerver.models import (
|
||||||
get_client,
|
get_client,
|
||||||
get_realm,
|
get_realm,
|
||||||
get_stream,
|
get_stream,
|
||||||
receives_offline_email_notifications,
|
|
||||||
receives_offline_push_notifications,
|
receives_offline_push_notifications,
|
||||||
receives_online_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:
|
def test_receivers_offline_notifications_when_user_is_a_bot(self) -> None:
|
||||||
self.user.is_bot = True
|
self.user.is_bot = True
|
||||||
|
|
||||||
self.user.enable_offline_email_notifications = True
|
|
||||||
self.user.enable_offline_push_notifications = True
|
self.user.enable_offline_push_notifications = True
|
||||||
self.assertFalse(receives_offline_push_notifications(self.user))
|
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.user.enable_offline_push_notifications = False
|
||||||
self.assertFalse(receives_offline_push_notifications(self.user))
|
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.user.enable_offline_push_notifications = False
|
||||||
self.assertFalse(receives_offline_push_notifications(self.user))
|
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.user.enable_offline_push_notifications = True
|
||||||
self.assertFalse(receives_offline_push_notifications(self.user))
|
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:
|
def test_receivers_offline_notifications_when_user_is_not_a_bot(self) -> None:
|
||||||
self.user.is_bot = False
|
self.user.is_bot = False
|
||||||
|
|
||||||
self.user.enable_offline_email_notifications = True
|
|
||||||
self.user.enable_offline_push_notifications = True
|
self.user.enable_offline_push_notifications = True
|
||||||
self.assertTrue(receives_offline_push_notifications(self.user))
|
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.user.enable_offline_push_notifications = False
|
||||||
self.assertFalse(receives_offline_push_notifications(self.user))
|
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.user.enable_offline_push_notifications = False
|
||||||
self.assertFalse(receives_offline_push_notifications(self.user))
|
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.user.enable_offline_push_notifications = True
|
||||||
self.assertTrue(receives_offline_push_notifications(self.user))
|
self.assertTrue(receives_offline_push_notifications(self.user))
|
||||||
self.assertFalse(receives_offline_email_notifications(self.user))
|
|
||||||
|
|
||||||
|
|
||||||
class TestPushNotificationsContent(ZulipTestCase):
|
class TestPushNotificationsContent(ZulipTestCase):
|
||||||
|
|
Loading…
Reference in New Issue