make sure we filter out empty target locales
This commit is contained in:
Родитель
38d2ad3510
Коммит
c152ed8a14
|
@ -23,13 +23,13 @@ def test_locale_display_name():
|
|||
assert_raises(KeyError, check, 'fake-lang', '', '')
|
||||
|
||||
|
||||
class TestView(test_utils.TestCase):
|
||||
class TestLanguageTools(test_utils.TestCase):
|
||||
fixtures = ['browse/test_views']
|
||||
|
||||
def setUp(self):
|
||||
cache.clear()
|
||||
url = reverse('browse.language_tools')
|
||||
response = self.client.get(url, follow=True)
|
||||
self.url = reverse('browse.language_tools')
|
||||
response = self.client.get(self.url, follow=True)
|
||||
self.locales = response.context['locales']
|
||||
|
||||
def test_sorting(self):
|
||||
|
@ -56,6 +56,24 @@ class TestView(test_utils.TestCase):
|
|||
eq_(len(ca.dicts), 1)
|
||||
eq_(len(ca.packs), 2)
|
||||
|
||||
def test_empty_target_locale(self):
|
||||
"""Make sure nothing breaks with empty target locales."""
|
||||
for addon in Addon.objects.all():
|
||||
addon.target_locale = ''
|
||||
addon.save()
|
||||
response = self.client.get(self.url, follow=True)
|
||||
eq_(response.status_code, 200)
|
||||
eq_(response.context['locales'], [])
|
||||
|
||||
def test_null_target_locale(self):
|
||||
"""Make sure nothing breaks with null target locales."""
|
||||
for addon in Addon.objects.all():
|
||||
addon.target_locale = None
|
||||
addon.save()
|
||||
response = self.client.get(self.url, follow=True)
|
||||
eq_(response.status_code, 200)
|
||||
eq_(response.context['locales'], [])
|
||||
|
||||
|
||||
class TestThemes(test_utils.TestCase):
|
||||
fixtures = ['base/addons']
|
||||
|
|
|
@ -41,8 +41,8 @@ Locale = collections.namedtuple('Locale', 'locale display native dicts packs')
|
|||
|
||||
def language_tools(request):
|
||||
types = (amo.ADDON_DICT, amo.ADDON_LPAPP)
|
||||
q = (Addon.objects.public().filter(type__in=types)
|
||||
.exclude(target_locale=''))
|
||||
q = (Addon.objects.public().exclude(target_locale='')
|
||||
.filter(type__in=types, target_locale__isnull=False))
|
||||
addons = [a for a in q.all() if request.APP in a.compatible_apps]
|
||||
|
||||
for addon in addons:
|
||||
|
|
Загрузка…
Ссылка в новой задаче