Added additional tests for translation's get_language_from_path().

This commit is contained in:
Krzysztof Urbaniak 2016-10-27 15:31:15 +02:00 committed by Tim Graham
parent 9513903086
commit ee06689878
1 changed files with 13 additions and 0 deletions

View File

@ -1472,11 +1472,24 @@ class MiscTests(SimpleTestCase):
r.META = {'HTTP_ACCEPT_LANGUAGE': 'de'} r.META = {'HTTP_ACCEPT_LANGUAGE': 'de'}
self.assertEqual(g(r), 'zh-hans') self.assertEqual(g(r), 'zh-hans')
@override_settings(
LANGUAGES=[
('en', 'English'),
('de', 'German'),
('de-at', 'Austrian German'),
('pl', 'Polish'),
],
)
def test_get_language_from_path_real(self): def test_get_language_from_path_real(self):
g = trans_real.get_language_from_path g = trans_real.get_language_from_path
self.assertEqual(g('/pl/'), 'pl') self.assertEqual(g('/pl/'), 'pl')
self.assertEqual(g('/pl'), 'pl') self.assertEqual(g('/pl'), 'pl')
self.assertIsNone(g('/xyz/')) self.assertIsNone(g('/xyz/'))
self.assertEqual(g('/en/'), 'en')
self.assertEqual(g('/en-gb/'), 'en')
self.assertEqual(g('/de/'), 'de')
self.assertEqual(g('/de-at/'), 'de-at')
self.assertEqual(g('/de-ch/'), 'de')
def test_get_language_from_path_null(self): def test_get_language_from_path_null(self):
from django.utils.translation.trans_null import get_language_from_path as g from django.utils.translation.trans_null import get_language_from_path as g