Exemplo n.º 1
0
 def test_html_welcome(self, apply_updates, send_message):
     """Test sending the right welcome message"""
     welcome = u'welcome'
     Newsletter.objects.create(
         slug='slug',
         vendor_id='VENDOR',
         welcome=welcome,
         languages='en,ru',
     )
     token = "TOKEN"
     email = '*****@*****.**'
     lang = 'RU'  # This guy had an uppercase lang code for some reason
     format = 'H'
     # User who prefers Russian HTML messages
     user_data = {
         'status': 'ok',
         'confirmed': False,
         'newsletters': ['slug'],
         'format': format,
         'lang': lang,
         'token': token,
         'email': email,
     }
     confirm_user(token, user_data)
     # Lang code is lowercased. And we don't append anything for HTML.
     expected_welcome = "%s_%s" % (lang.lower(), welcome)
     send_message.assert_called_with(expected_welcome, email, token, format)
Exemplo n.º 2
0
 def test_text_welcome(self, apply_updates, send_message):
     """Test sending the right welcome message"""
     welcome = u'welcome'
     Newsletter.objects.create(
         slug='slug',
         vendor_id='VENDOR',
         welcome=welcome,
         languages='en,ru',
     )
     token = "TOKEN"
     email = '*****@*****.**'
     lang = 'ru'
     format = 'T'
     # User who prefers Russian Text messages
     user_data = {
         'status': 'ok',
         'confirmed': False,
         'newsletters': ['slug'],
         'format': format,
         'lang': lang,
         'token': token,
         'email': email,
     }
     confirm_user(token, user_data)
     expected_welcome = "%s_%s_%s" % (lang, welcome, format)
     send_message.assert_called_with(expected_welcome, email, token, format)
Exemplo n.º 3
0
 def test_other_long_lang_welcome(self, apply_updates, send_message):
     """Test sending welcome in pt if the user wants pt-Br and the
     newsletter supports pt"""
     welcome = u'welcome'
     Newsletter.objects.create(
         slug='slug',
         vendor_id='VENDOR',
         welcome=welcome,
         languages='en,ru,pt',
     )
     token = "TOKEN"
     email = '*****@*****.**'
     lang = 'pt-Br'
     format = 'H'
     user_data = {
         'status': 'ok',
         'confirmed': False,
         'newsletters': ['slug'],
         'format': format,
         'lang': lang,
         'token': token,
         'email': email,
     }
     confirm_user(token, user_data)
     # They're getting pt. And we don't append anything for HTML.
     expected_welcome = "pt_%s" % welcome
     send_message.assert_called_with(expected_welcome, email, token, format)
Exemplo n.º 4
0
 def test_one_lang_welcome(self, apply_updates, send_message):
     """If a newsletter only has one language, the welcome message
     still gets a language prefix"""
     welcome = u'welcome'
     Newsletter.objects.create(
         slug='slug',
         vendor_id='VENDOR',
         welcome=welcome,
         languages='en',
     )
     token = "TOKEN"
     email = '*****@*****.**'
     lang = 'pt-Br'
     format = 'H'
     user_data = {
         'status': 'ok',
         'confirmed': False,
         'newsletters': ['slug'],
         'format': format,
         'lang': lang,
         'token': token,
         'email': email,
     }
     confirm_user(token, user_data)
     expected_welcome = 'en_' + welcome
     send_message.assert_called_with(expected_welcome, email, token, format)
Exemplo n.º 5
0
 def test_bad_lang_welcome(self, apply_updates, send_message):
     """Test sending welcome in english if user wants a lang that
     our newsletter doesn't support"""
     welcome = u'welcome'
     Newsletter.objects.create(
         slug='slug',
         vendor_id='VENDOR',
         welcome=welcome,
         languages='en,ru',
     )
     token = "TOKEN"
     email = '*****@*****.**'
     lang = 'fr'
     format = 'H'
     # User who prefers French HTML messages
     user_data = {
         'status': 'ok',
         'confirmed': False,
         'newsletters': ['slug'],
         'format': format,
         'lang': lang,
         'token': token,
         'email': email,
     }
     confirm_user(token, user_data)
     # They're getting English. And we don't append anything for HTML.
     expected_welcome = "en_%s" % welcome
     send_message.assert_called_with(expected_welcome, email, token, format)