|
@@ -4,6 +4,8 @@ import os
|
|
|
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
|
|
from django.core.urlresolvers import reverse, clear_url_caches
|
|
|
+from django.http import HttpResponsePermanentRedirect
|
|
|
+from django.middleware.locale import LocaleMiddleware
|
|
|
from django.test import TestCase
|
|
|
from django.test.utils import override_settings
|
|
|
from django.template import Template, Context
|
|
@@ -11,6 +13,10 @@ from django.utils._os import upath
|
|
|
from django.utils import translation
|
|
|
|
|
|
|
|
|
+class PermanentRedirectLocaleMiddleWare(LocaleMiddleware):
|
|
|
+ response_redirect_class = HttpResponsePermanentRedirect
|
|
|
+
|
|
|
+
|
|
|
@override_settings(
|
|
|
USE_I18N=True,
|
|
|
LOCALE_PATHS=(
|
|
@@ -181,6 +187,16 @@ class URLRedirectTests(URLTestCaseBase):
|
|
|
response = self.client.get(response['location'])
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
+ @override_settings(
|
|
|
+ MIDDLEWARE_CLASSES=(
|
|
|
+ 'i18n.patterns.tests.PermanentRedirectLocaleMiddleWare',
|
|
|
+ 'django.middleware.common.CommonMiddleware',
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ def test_custom_redirect_class(self):
|
|
|
+ response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='en')
|
|
|
+ self.assertRedirects(response, '/en/account/register/', 301)
|
|
|
+
|
|
|
|
|
|
class URLVaryAcceptLanguageTests(URLTestCaseBase):
|
|
|
"""
|