コード例 #1
0
ファイル: test_tasks.py プロジェクト: mozmar/basket
    def test_et_error(self, mock_look_for_user, mock_send):
        """Error talking to Basket. I'm shocked, SHOCKED!"""
        mock_look_for_user.side_effect = NewsletterException('ET has failed to achieve.')

        with self.assertRaises(NewsletterException):
            send_recovery_message_task(self.email)

        self.assertFalse(mock_send.called)
コード例 #2
0
    def test_et_error(self, mock_look_for_user, mock_send):
        """Error talking to Basket. I'm shocked, SHOCKED!"""
        mock_look_for_user.side_effect = NewsletterException(
            'ET has failed to achieve.')

        with self.assertRaises(NewsletterException):
            send_recovery_message_task(self.email)

        self.assertFalse(mock_send.called)
コード例 #3
0
ファイル: test_tasks.py プロジェクト: mozmar/basket
 def test_lang_not_available(self, mock_look_for_user, mock_send):
     """Language not available for recover message"""
     # Should trigger message in english if not available in user lang
     format = 'T'
     mock_look_for_user.return_value = {
         'id': 'SFDCID',
         'status': 'ok',
         'email': self.email,
         'format': format,
         'country': '',
         'lang': 'fr',
         'token': 'USERTOKEN',
         'newsletters': [],
     }
     send_recovery_message_task(self.email)
     message_id = mogrify_message_id(RECOVERY_MESSAGE_ID, 'en', format)
     mock_send.delay.assert_called_with(message_id, self.email, 'SFDCID',
                                        token='USERTOKEN')
コード例 #4
0
ファイル: test_tasks.py プロジェクト: mozmar/basket
 def test_email_in_et(self, mock_look_for_user, mock_send):
     """Email not in basket but in ET"""
     # Should trigger message. We can follow the user's format and lang pref
     format = 'T'
     lang = 'fr'
     mock_look_for_user.return_value = {
         'id': 'SFDCID',
         'status': 'ok',
         'email': self.email,
         'format': format,
         'country': '',
         'lang': lang,
         'token': 'USERTOKEN',
         'newsletters': [],
     }
     send_recovery_message_task(self.email)
     message_id = mogrify_message_id(RECOVERY_MESSAGE_ID, lang, format)
     mock_send.delay.assert_called_with(message_id, self.email, 'SFDCID',
                                        token='USERTOKEN')
コード例 #5
0
 def test_lang_not_available(self, mock_look_for_user, mock_send):
     """Language not available for recover message"""
     # Should trigger message in english if not available in user lang
     format = 'T'
     mock_look_for_user.return_value = {
         'id': 'SFDCID',
         'status': 'ok',
         'email': self.email,
         'format': format,
         'country': '',
         'lang': 'fr',
         'token': 'USERTOKEN',
         'newsletters': [],
     }
     send_recovery_message_task(self.email)
     message_id = mogrify_message_id(RECOVERY_MESSAGE_ID, 'en', format)
     mock_send.delay.assert_called_with(message_id,
                                        self.email,
                                        'SFDCID',
                                        token='USERTOKEN')
コード例 #6
0
 def test_email_in_et(self, mock_look_for_user, mock_send):
     """Email not in basket but in ET"""
     # Should trigger message. We can follow the user's format and lang pref
     format = 'T'
     lang = 'fr'
     mock_look_for_user.return_value = {
         'id': 'SFDCID',
         'status': 'ok',
         'email': self.email,
         'format': format,
         'country': '',
         'lang': lang,
         'token': 'USERTOKEN',
         'newsletters': [],
     }
     send_recovery_message_task(self.email)
     message_id = mogrify_message_id(RECOVERY_MESSAGE_ID, lang, format)
     mock_send.delay.assert_called_with(message_id,
                                        self.email,
                                        'SFDCID',
                                        token='USERTOKEN')
コード例 #7
0
 def test_unknown_email(self, mock_look_for_user, mock_send):
     """Email not in basket or ET"""
     # Should log error and return
     mock_look_for_user.return_value = None
     send_recovery_message_task(self.email)
     self.assertFalse(mock_send.called)
コード例 #8
0
ファイル: test_tasks.py プロジェクト: mozmar/basket
 def test_unknown_email(self, mock_look_for_user, mock_send):
     """Email not in basket or ET"""
     # Should log error and return
     mock_look_for_user.return_value = None
     send_recovery_message_task(self.email)
     self.assertFalse(mock_send.called)