def test_24h_digest_email(self): user = create_user(email="*****@*****.**") pn = Actions.digest(user) notification = Notification.from_pending_notification(pn, user, "EmailChannel") email_message = EmailChannel().make_message(notification, force=True) message = EmailChannel().make_email_backend_message(email_message) email_message.record_sent(notification.action)
def test_user_can_unsubscribe_through_header_link(self): user = create_user(email="*****@*****.**") comment = create_comment() comment2 = create_comment(author=user, replied_comment=comment) pn = Actions.replied(user, comment2) notification = Notification.from_pending_notification(pn, user, "EmailChannel") email_message = EmailChannel().make_message(notification, force=True) message = EmailChannel().make_email_backend_message(email_message) email_message.record_sent(notification.action) assert message.extra_headers unsubscribe_link = message.extra_headers.get("List-Unsubscribe") assert unsubscribe_link # Use should be able to receive notifications ... self.assertTrue(user.kv.subscriptions.can_receive('replied')) # Now, 'curl' the unsubscribe link self.assertStatus(200, unsubscribe_link) # Now, this action should be disabled in the notifications subscriptions. self.assertFalse(user.kv.subscriptions.can_receive('replied'))
def test_user_can_unsubscribe_through_header_link(self): user = create_user(email="*****@*****.**") comment = create_comment() comment2 = create_comment(author=user, replied_comment=comment) pn = Actions.replied(user, comment2) notification = Notification.from_pending_notification(pn, user, "EmailChannel") email_message = EmailChannel().make_message(notification, force=True) message = EmailChannel().make_email_backend_message(email_message) email_message.record_sent(notification.action) assert message.extra_headers unsubscribe_link = message.extra_headers.get("List-Unsubscribe") assert unsubscribe_link # Use should be able to receive notifications ... self.assertTrue(user.kv.subscriptions.can_receive("replied")) # Now, 'curl' the unsubscribe link self.assertStatus(200, unsubscribe_link) # Now, this action should be disabled in the notifications subscriptions. self.assertFalse(user.kv.subscriptions.can_receive("replied"))