コード例 #1
0
    def test_includes_unsubscribe_link(self, mock):
        """Ensure that the unsubscribe link is in the email"""
        user = mommy.make('accounts.User')
        notification = mommy.make(Notification,
                                  recipient=user,
                                  message=self.message1)
        tasks.send_immediate_notification(notification.pk)
        mock.assert_called_once()

        args = mock.call_args[1]

        self.assertIn('unsubscribe', args['html'].lower())
        self.assertIn(user.unsubscribe_url, args['html'])
        self.assertIn('unsubscribe', args['text'].lower())
        self.assertIn(user.unsubscribe_url, args['text'])
コード例 #2
0
ファイル: test_tasks.py プロジェクト: mgifford/connect
    def test_includes_unsubscribe_link(self, mock):
        """Ensure that the unsubscribe link is in the email"""
        user = mommy.make('accounts.User')
        notification = mommy.make(
            Notification,
            recipient=user,
            message=self.message1
        )
        tasks.send_immediate_notification(notification.pk)
        mock.assert_called_once()

        args = mock.call_args[1]

        self.assertIn('unsubscribe', args['html'].lower())
        self.assertIn(user.unsubscribe_url, args['html'])
        self.assertIn('unsubscribe', args['text'].lower())
        self.assertIn(user.unsubscribe_url, args['text'])
コード例 #3
0
ファイル: test_tasks.py プロジェクト: mklaber/connect
    def test_called(self, mock):
        """Test to make sure that the emailer was properly called"""
        user = mommy.make('accounts.User')
        notification = mommy.make(Notification,
                                  recipient=user,
                                  message=self.message1)

        self.assertIsNone(notification.consumed_at)

        tasks.send_immediate_notification(notification.pk)
        self.assertIsNotNone(
            Notification.objects.get(pk=notification.pk).consumed_at)
        mock.assert_called_once()

        args = mock.call_args[1]

        # To
        email = args['email']
        self.assertIn(user.email, email)
        self.assertIn(user.get_full_name(), email)

        # From
        from_email = args['from_email']
        self.assertIn(settings.DEFAULT_FROM_ADDRESS, from_email)
        self.assertIn('Connect Test', from_email)
        self.assertIn(self.message1.sender.get_full_name(), from_email)

        # Subject
        subject = args['subject']
        self.assertIn(str(self.message1.thread.group), subject)
        self.assertIn(self.message1.thread.subject, subject)

        # Body (HTML and Plaintext)
        html = args['html']
        plaintext = args['text']
        self.assertIn(self.message1.text, html)
        self.assertIn('Reply', html)
        self.assertIn(self.message1.clean_text, plaintext)
コード例 #4
0
ファイル: test_tasks.py プロジェクト: mgifford/connect
    def test_called(self, mock):
        """Test to make sure that the emailer was properly called"""
        user = mommy.make('accounts.User')
        notification = mommy.make(
            Notification,
            recipient=user, message=self.message1)

        self.assertFalse(notification.consumed)

        tasks.send_immediate_notification(notification.pk)
        self.assertTrue(
            Notification.objects.get(pk=notification.pk).consumed)
        mock.assert_called_once()

        args = mock.call_args[1]

        # To
        email = args['email']
        self.assertIn(user.email, email)
        self.assertIn(user.get_full_name(), email)

        # From
        from_email = args['from_email']
        self.assertIn(settings.DEFAULT_FROM_ADDRESS, from_email)
        self.assertIn('Connect Test', from_email)
        self.assertIn(self.message1.sender.get_full_name(), from_email)

        # Subject
        subject = args['subject']
        self.assertIn(str(self.message1.thread.group), subject)
        self.assertIn(self.message1.thread.subject, subject)

        # Body (HTML and Plaintext)
        html = args['html']
        plaintext = args['text']
        self.assertIn(self.message1.text, html)
        self.assertIn('Reply', html)
        self.assertIn(self.message1.clean_text, plaintext)
コード例 #5
0
    def test_called_direct_message(self, mock):
        """Test triggering the notification system with a direct message"""
        user = mommy.make('accounts.User')
        notification = mommy.make(Notification,
                                  recipient=user,
                                  message=self.directmessage1)

        self.assertFalse(notification.consumed)

        tasks.send_immediate_notification(notification.pk)
        self.assertIsNotNone(
            Notification.objects.get(pk=notification.pk).consumed)
        mock.assert_called_once()

        args = mock.call_args[1]

        # To
        email = args['email']
        self.assertIn(user.email, email)
        self.assertIn(user.get_full_name(), email)

        # From
        from_email = args['from_email']
        self.assertIn(settings.DEFAULT_FROM_ADDRESS, from_email)
        self.assertIn('Connect Test', from_email)
        self.assertIn(self.directmessage1.sender.get_full_name(), from_email)

        # Subject
        subject = args['subject']
        self.assertEqual(self.directmessage1.thread.subject, subject)

        # Body (HTML and Plaintext)
        html = args['html']
        plaintext = args['text']
        self.assertIn(self.directmessage1.text, html)
        self.assertIn('Reply', html)
        self.assertIn(self.directmessage1.clean_text, plaintext)
コード例 #6
0
ファイル: test_tasks.py プロジェクト: mgifford/connect
    def test_called_direct_message(self, mock):
        """Test triggering the notification system with a direct message"""
        user = mommy.make('accounts.User')
        notification = mommy.make(
            Notification,
            recipient=user, message=self.directmessage1)

        self.assertFalse(notification.consumed)

        tasks.send_immediate_notification(notification.pk)
        self.assertIsNotNone(
            Notification.objects.get(pk=notification.pk).consumed)
        mock.assert_called_once()

        args = mock.call_args[1]

        # To
        email = args['email']
        self.assertIn(user.email, email)
        self.assertIn(user.get_full_name(), email)

        # From
        from_email = args['from_email']
        self.assertIn(settings.DEFAULT_FROM_ADDRESS, from_email)
        self.assertIn('Connect Test', from_email)
        self.assertIn(self.directmessage1.sender.get_full_name(), from_email)

        # Subject
        subject = args['subject']
        self.assertEqual(self.directmessage1.thread.subject, subject)

        # Body (HTML and Plaintext)
        html = args['html']
        plaintext = args['text']
        self.assertIn(self.directmessage1.text, html)
        self.assertIn('Reply', html)
        self.assertIn(self.directmessage1.clean_text, plaintext)