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', '', '')
|
assert_raises(KeyError, check, 'fake-lang', '', '')
|
||||||
|
|
||||||
|
|
||||||
class TestView(test_utils.TestCase):
|
class TestLanguageTools(test_utils.TestCase):
|
||||||
fixtures = ['browse/test_views']
|
fixtures = ['browse/test_views']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
cache.clear()
|
cache.clear()
|
||||||
url = reverse('browse.language_tools')
|
self.url = reverse('browse.language_tools')
|
||||||
response = self.client.get(url, follow=True)
|
response = self.client.get(self.url, follow=True)
|
||||||
self.locales = response.context['locales']
|
self.locales = response.context['locales']
|
||||||
|
|
||||||
def test_sorting(self):
|
def test_sorting(self):
|
||||||
|
@ -56,6 +56,24 @@ class TestView(test_utils.TestCase):
|
||||||
eq_(len(ca.dicts), 1)
|
eq_(len(ca.dicts), 1)
|
||||||
eq_(len(ca.packs), 2)
|
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):
|
class TestThemes(test_utils.TestCase):
|
||||||
fixtures = ['base/addons']
|
fixtures = ['base/addons']
|
||||||
|
|
|
@ -41,8 +41,8 @@ Locale = collections.namedtuple('Locale', 'locale display native dicts packs')
|
||||||
|
|
||||||
def language_tools(request):
|
def language_tools(request):
|
||||||
types = (amo.ADDON_DICT, amo.ADDON_LPAPP)
|
types = (amo.ADDON_DICT, amo.ADDON_LPAPP)
|
||||||
q = (Addon.objects.public().filter(type__in=types)
|
q = (Addon.objects.public().exclude(target_locale='')
|
||||||
.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]
|
addons = [a for a in q.all() if request.APP in a.compatible_apps]
|
||||||
|
|
||||||
for addon in addons:
|
for addon in addons:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче