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)
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)
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')
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')
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)