mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-10-30 14:49:14 +00:00
43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
from sentry.newsletter.dummy import DummyNewsletter
|
|
from sentry.testutils.cases import TestCase
|
|
from sentry.testutils.silo import control_silo_test
|
|
|
|
|
|
@control_silo_test
|
|
class DummyNewsletterTest(TestCase):
|
|
def setUp(self):
|
|
self.newsletter = DummyNewsletter()
|
|
|
|
def test_defaults(self):
|
|
assert self.newsletter.DEFAULT_LISTS == self.newsletter.get_default_list_ids()
|
|
assert self.newsletter.DEFAULT_LIST_ID == self.newsletter.get_default_list_id()
|
|
|
|
def assert_subscriptions(self, user, count):
|
|
subscriptions = self.newsletter.get_subscriptions(user)
|
|
assert subscriptions.get("subscriptions") is not None
|
|
subscribed = [sub for sub in subscriptions["subscriptions"] if sub.subscribed]
|
|
assert len(subscribed) == count
|
|
|
|
def test_update_subscription(self):
|
|
user = self.create_user("[email protected]")
|
|
|
|
self.assert_subscriptions(user, 0)
|
|
self.newsletter.create_or_update_subscription(user)
|
|
self.assert_subscriptions(user, 1)
|
|
|
|
def test_update_subscriptions(self):
|
|
user = self.create_user("[email protected]")
|
|
|
|
self.assert_subscriptions(user, 0)
|
|
self.newsletter.create_or_update_subscriptions(user)
|
|
self.assert_subscriptions(user, 1)
|
|
|
|
def test_optout_email(self):
|
|
user = self.create_user("[email protected]")
|
|
|
|
self.newsletter.create_or_update_subscriptions(user)
|
|
self.assert_subscriptions(user, 1)
|
|
|
|
self.newsletter.optout_email("[email protected]")
|
|
self.assert_subscriptions(user, 0)
|