summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Kolosov <m17.admin@gmail.com>2013-05-19 12:20:34 +0200
committerTim Graham <timograham@gmail.com>2014-03-01 07:52:45 -0500
commit8c98f39624a60c63a16e097b64e5f71ecc27271f (patch)
treeeaa99e953f3f4cab4d7e00c7d1fb494ca8eb1235 /tests
parentc679cb7f600b13646a1a2b5fc8a03dfcc2e413f2 (diff)
Fixed #15318 -- Added settings for language cookie max-age, path, domain
Introduced a number of settings to configure max-age, path, and domain for the language cookie: LANGUAGE_COOKIE_AGE, LANGUAGE_COOKIE_PATH and LANGUAGE_COOKIE_DOMAIN. Thanks sahid for the suggestion.
Diffstat (limited to 'tests')
-rw-r--r--tests/view_tests/tests/test_i18n.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py
index 7d6466d44f..d837f4bc90 100644
--- a/tests/view_tests/tests/test_i18n.py
+++ b/tests/view_tests/tests/test_i18n.py
@@ -51,6 +51,25 @@ class I18NTests(TestCase):
def test_setlang_reversal(self):
self.assertEqual(reverse('set_language'), '/i18n/setlang/')
+ def test_setlang_cookie(self):
+ # we force saving language to a cookie rather than a session
+ # by excluding session middleware and those which do require it
+ test_settings = dict(
+ MIDDLEWARE_CLASSES=('django.middleware.common.CommonMiddleware',),
+ LANGUAGE_COOKIE_NAME='mylanguage',
+ LANGUAGE_COOKIE_AGE=3600 * 7 * 2,
+ LANGUAGE_COOKIE_DOMAIN='.example.com',
+ LANGUAGE_COOKIE_PATH='/test/',
+ )
+ with self.settings(**test_settings):
+ post_data = dict(language='pl', next='/views/')
+ response = self.client.post('/i18n/setlang/', data=post_data)
+ language_cookie = response.cookies.get('mylanguage')
+ self.assertEqual(language_cookie.value, 'pl')
+ self.assertEqual(language_cookie['domain'], '.example.com')
+ self.assertEqual(language_cookie['path'], '/test/')
+ self.assertEqual(language_cookie['max-age'], 3600 * 7 * 2)
+
def test_jsi18n(self):
"""The javascript_catalog can be deployed with language settings"""
for lang_code in ['es', 'fr', 'ru']: