Exemplo n.º 1
0
 def test_default_confirm_notice_H(self, send_message):
     """Test newsletter that has no explicit confirm"""
     send_confirm_notice(self.email, self.token, "en", "H", ['slug2'])
     expected_message = mogrify_message_id(CONFIRMATION_MESSAGE, 'en', 'H')
     send_message.delay.assert_called_with(expected_message,
                                           self.email,
                                           self.token,
                                           'H')
Exemplo n.º 2
0
 def test_default_confirm_notice_short_for_long(self, send_message):
     """Test using short form of lang that's in the newsletter list as a long lang"""
     send_confirm_notice(self.email, self.token, "rr", "H", ['slug2'])
     expected_message = mogrify_message_id(CONFIRMATION_MESSAGE, 'rr', 'H')
     send_message.delay.assert_called_with(expected_message,
                                           self.email,
                                           self.token,
                                           'H')
Exemplo n.º 3
0
 def test_default_confirm_notice_long_lang_T(self, send_message):
     """Test newsletter that has no explicit confirm with long lang code"""
     send_confirm_notice(self.email, self.token, "es-ES", "T", ['slug2'])
     expected_message = mogrify_message_id(CONFIRMATION_MESSAGE, 'es', 'T')
     send_message.delay.assert_called_with(expected_message,
                                           self.email,
                                           self.token,
                                           'T')
Exemplo n.º 4
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 = {
         '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,
                                        'USERTOKEN', format)
Exemplo n.º 5
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 = {
         '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,
                                        'USERTOKEN', format)
Exemplo n.º 6
0
 def test_email_in_both(self, mock_look_for_user, mock_send):
     """Email known in both basket and ET"""
     # We can follow the user's format and lang pref
     subscriber = Subscriber.objects.create(email=self.email)
     format = 'T'
     lang = 'fr'
     mock_look_for_user.return_value = {
         'status': 'ok',
         'email': self.email,
         'format': format,
         'country': '',
         'lang': lang,
         'token': subscriber.token,
         'newsletters': [],
     }
     send_recovery_message_task(self.email)
     message_id = mogrify_message_id(RECOVERY_MESSAGE_ID, lang, format)
     mock_send.assert_called_with(message_id, self.email, subscriber.token,
                                  format)
Exemplo n.º 7
0
 def test_email_in_both(self, mock_look_for_user, mock_send):
     """Email known in both basket and ET"""
     # We can follow the user's format and lang pref
     subscriber = Subscriber.objects.create(email=self.email)
     format = 'T'
     lang = 'fr'
     mock_look_for_user.return_value = {
         'status': 'ok',
         'email': self.email,
         'format': format,
         'country': '',
         'lang': lang,
         'token': subscriber.token,
         '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,
                                        subscriber.token, format)
Exemplo n.º 8
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')
Exemplo n.º 9
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')
Exemplo n.º 10
0
 def test_email_only_in_et(self, mock_look_for_user, mock_send):
     """Email not in basket but in ET"""
     # Should create new subscriber with ET data, then trigger message
     # We can follow the user's format and lang pref
     format = 'T'
     lang = 'fr'
     mock_look_for_user.return_value = {
         'status': 'ok',
         'email': self.email,
         'format': format,
         'country': '',
         'lang': lang,
         'token': 'USERTOKEN',
         'newsletters': [],
     }
     send_recovery_message_task(self.email)
     subscriber = Subscriber.objects.get(email=self.email)
     self.assertEqual('USERTOKEN', subscriber.token)
     message_id = mogrify_message_id(RECOVERY_MESSAGE_ID, lang, format)
     mock_send.assert_called_with(message_id, self.email, subscriber.token,
                                  format)
Exemplo n.º 11
0
 def test_email_only_in_et(self, mock_look_for_user, mock_send):
     """Email not in basket but in ET"""
     # Should create new subscriber with ET data, then trigger message
     # We can follow the user's format and lang pref
     format = 'T'
     lang = 'fr'
     mock_look_for_user.return_value = {
         'status': 'ok',
         'email': self.email,
         'format': format,
         'country': '',
         'lang': lang,
         'token': 'USERTOKEN',
         'newsletters': [],
     }
     send_recovery_message_task(self.email)
     subscriber = Subscriber.objects.get(email=self.email)
     self.assertEqual('USERTOKEN', subscriber.token)
     message_id = mogrify_message_id(RECOVERY_MESSAGE_ID, lang, format)
     mock_send.delay.assert_called_with(message_id, self.email,
                                        subscriber.token, format)
Exemplo n.º 12
0
 def test_mogrify_message_id_upcase_lang(self):
     """Test adding uppercase lang and format to message ID"""
     result = mogrify_message_id("MESSAGE", "FR", "T")
     expect = "fr_MESSAGE_T"
     self.assertEqual(expect, result)
Exemplo n.º 13
0
 def test_mogrify_message_id_long_lang(self):
     """Test adding long lang and format to message ID"""
     result = mogrify_message_id("MESSAGE", "en-US", "T")
     expect = "en_MESSAGE_T"
     self.assertEqual(expect, result)
Exemplo n.º 14
0
 def test_mogrify_message_id_no_lang(self):
     """Test adding no lang and format to message ID"""
     result = mogrify_message_id("MESSAGE", None, "T")
     expect = "MESSAGE_T"
     self.assertEqual(expect, result)
Exemplo n.º 15
0
 def test_mogrify_message_id_html(self):
     """Test adding lang and html format to message ID"""
     result = mogrify_message_id("MESSAGE", "en", "H")
     expect = "en_MESSAGE"
     self.assertEqual(expect, result)
Exemplo n.º 16
0
 def test_mogrify_message_id_html(self):
     """Test adding lang and html format to message ID"""
     result = mogrify_message_id("MESSAGE", "en", "H")
     expect = "en_MESSAGE"
     self.assertEqual(expect, result)
Exemplo n.º 17
0
 def test_default_confirm_notice_long_lang_T(self, send_message):
     """Test newsletter that has no explicit confirm with long lang code"""
     send_confirm_notice(self.email, self.token, "es-ES", "T", ['slug2'])
     expected_message = mogrify_message_id(CONFIRMATION_MESSAGE, 'es', 'T')
     send_message.assert_called_with(expected_message, self.email,
                                     self.token, 'T')
Exemplo n.º 18
0
 def test_default_confirm_notice_short_for_long(self, send_message):
     """Test using short form of lang that's in the newsletter list as a long lang"""
     send_confirm_notice(self.email, self.token, "rr", "H", ['slug2'])
     expected_message = mogrify_message_id(CONFIRMATION_MESSAGE, 'rr', 'H')
     send_message.assert_called_with(expected_message, self.email,
                                     self.token, 'H')
Exemplo n.º 19
0
 def test_default_confirm_notice_H(self, send_message):
     """Test newsletter that has no explicit confirm"""
     send_confirm_notice(self.email, self.token, "en", "H", ['slug2'])
     expected_message = mogrify_message_id(CONFIRMATION_MESSAGE, 'en', 'H')
     send_message.assert_called_with(expected_message, self.email,
                                     self.token, 'H')
Exemplo n.º 20
0
 def test_mogrify_message_id_no_lang(self):
     """Test adding no lang and format to message ID"""
     result = mogrify_message_id("MESSAGE", None, "T")
     expect = "MESSAGE_T"
     self.assertEqual(expect, result)
Exemplo n.º 21
0
 def test_mogrify_message_id_upcase_lang(self):
     """Test adding uppercase lang and format to message ID"""
     result = mogrify_message_id("MESSAGE", "FR", "T")
     expect = "fr_MESSAGE_T"
     self.assertEqual(expect, result)
Exemplo n.º 22
0
 def test_mogrify_message_id_long_lang(self):
     """Test adding long lang and format to message ID"""
     result = mogrify_message_id("MESSAGE", "en-US", "T")
     expect = "en_MESSAGE_T"
     self.assertEqual(expect, result)