BOM-622 Type errors in content matching.

This commit is contained in:
Feanil Patel
2019-09-19 16:18:23 -04:00
parent 4eaf875741
commit 802929fde4
4 changed files with 29 additions and 29 deletions

View File

@@ -80,30 +80,30 @@ class I18nTestCase(BaseI18nTestCase):
def test_default_is_en(self):
self.release_languages('fr')
response = self.client.get('/')
self.assert_tag_has_attr(response.content, "html", "lang", "en")
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "en")
self.assertEqual(response['Content-Language'], 'en')
self.assert_tag_has_attr(response.content, "body", "class", "lang_en")
self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "lang_en")
def test_esperanto(self):
self.release_languages('fr, eo')
response = self.client.get('/', HTTP_ACCEPT_LANGUAGE='eo')
self.assert_tag_has_attr(response.content, "html", "lang", "eo")
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "eo")
self.assertEqual(response['Content-Language'], 'eo')
self.assert_tag_has_attr(response.content, "body", "class", "lang_eo")
self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "lang_eo")
def test_switching_languages_bidi(self):
self.release_languages('ar, eo')
response = self.client.get('/')
self.assert_tag_has_attr(response.content, "html", "lang", "en")
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "en")
self.assertEqual(response['Content-Language'], 'en')
self.assert_tag_has_attr(response.content, "body", "class", "lang_en")
self.assert_tag_has_attr(response.content, "body", "class", "ltr")
self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "lang_en")
self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "ltr")
response = self.client.get('/', HTTP_ACCEPT_LANGUAGE='ar')
self.assert_tag_has_attr(response.content, "html", "lang", "ar")
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "ar")
self.assertEqual(response['Content-Language'], 'ar')
self.assert_tag_has_attr(response.content, "body", "class", "lang_ar")
self.assert_tag_has_attr(response.content, "body", "class", "rtl")
self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "lang_ar")
self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "rtl")
class I18nRegressionTests(BaseI18nTestCase):
@@ -114,7 +114,7 @@ class I18nRegressionTests(BaseI18nTestCase):
# Regression test; LOC-72, and an issue with Django
self.release_languages('es-419')
response = self.client.get('/', HTTP_ACCEPT_LANGUAGE='es-419')
self.assert_tag_has_attr(response.content, "html", "lang", "es-419")
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "es-419")
def test_unreleased_lang_resolution(self):
# Regression test; LOC-85
@@ -126,12 +126,12 @@ class I18nRegressionTests(BaseI18nTestCase):
# in the http request (NOT with the ?preview-lang query param) should
# receive files for 'fa'
response = self.client.get(self.url, HTTP_ACCEPT_LANGUAGE='fa-ir')
self.assert_tag_has_attr(response.content, "html", "lang", "fa")
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "fa")
# Now try to access with dark lang
self.client.post(self.preview_language_url, {'preview_language': 'fa-ir', 'action': 'set_preview_language'})
response = self.client.get(self.url)
self.assert_tag_has_attr(response.content, "html", "lang", "fa-ir")
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "fa-ir")
def test_preview_lang(self):
self.user_login()
@@ -141,23 +141,23 @@ class I18nRegressionTests(BaseI18nTestCase):
site_lang = settings.LANGUAGE_CODE
# Visit the front page; verify we see site default lang
response = self.client.get(self.url)
self.assert_tag_has_attr(response.content, "html", "lang", site_lang)
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", site_lang)
# Verify we can switch language using the preview-lang query param
# Set the language
self.client.post(self.preview_language_url, {'preview_language': 'eo', 'action': 'set_preview_language'})
response = self.client.get(self.url)
self.assert_tag_has_attr(response.content, "html", "lang", "eo")
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "eo")
# We should be able to see released languages using preview-lang, too
self.client.post(self.preview_language_url, {'preview_language': 'es-419', 'action': 'set_preview_language'})
response = self.client.get(self.url)
self.assert_tag_has_attr(response.content, "html", "lang", "es-419")
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "es-419")
# Clearing the language should go back to site default
self.client.post(self.preview_language_url, {'action': 'reset_preview_language'})
response = self.client.get(self.url)
self.assert_tag_has_attr(response.content, "html", "lang", site_lang)
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", site_lang)
class I18nLangPrefTests(BaseI18nTestCase):
@@ -187,18 +187,18 @@ class I18nLangPrefTests(BaseI18nTestCase):
# Visit the front page; verify we see site default lang
response = self.client.get(self.url)
self.assert_tag_has_attr(response.content, "html", "lang", self.site_lang)
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", self.site_lang)
# Set user language preference
self.set_lang_preference('ar')
# and verify we now get an ar response
response = self.client.get(self.url)
self.assert_tag_has_attr(response.content, "html", "lang", 'ar')
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", 'ar')
# Verify that switching language preference gives the right language
self.set_lang_preference('es-419')
response = self.client.get(self.url)
self.assert_tag_has_attr(response.content, "html", "lang", 'es-419')
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", 'es-419')
def test_preview_precedence(self):
# Regression test; LOC-87
@@ -210,13 +210,13 @@ class I18nLangPrefTests(BaseI18nTestCase):
self.client.post(self.preview_language_url, {'preview_language': 'eo', 'action': 'set_preview_language'})
response = self.client.get(self.url)
self.assert_tag_has_attr(response.content, "html", "lang", 'eo')
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", 'eo')
# Hitting another page should keep the dark language set.
response = self.client.get(reverse('courses'))
self.assert_tag_has_attr(response.content, "html", "lang", "eo")
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "eo")
# Clearing language must set language back to preference language
self.client.post(self.preview_language_url, {'action': 'reset_preview_language'})
response = self.client.get(self.url)
self.assert_tag_has_attr(response.content, "html", "lang", 'ar')
self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", 'ar')