2015-04-18 05:38:20 +08:00
|
|
|
from django.test import SimpleTestCase, override_settings
|
2009-04-12 11:50:47 +08:00
|
|
|
|
2011-04-02 21:27:40 +08:00
|
|
|
|
2014-04-05 14:04:46 +08:00
|
|
|
@override_settings(ROOT_URLCONF='view_tests.generic_urls')
|
2015-04-18 05:38:20 +08:00
|
|
|
class URLHandling(SimpleTestCase):
|
2009-04-12 11:50:47 +08:00
|
|
|
"""
|
|
|
|
Tests for URL handling in views and responses.
|
|
|
|
"""
|
2011-04-02 21:27:40 +08:00
|
|
|
redirect_target = "/%E4%B8%AD%E6%96%87/target/"
|
|
|
|
|
2010-03-03 03:37:48 +08:00
|
|
|
def test_nonascii_redirect(self):
|
|
|
|
"""
|
2016-10-27 15:53:39 +08:00
|
|
|
A non-ASCII argument to HttpRedirect is handled properly.
|
2010-03-03 03:37:48 +08:00
|
|
|
"""
|
2011-04-02 21:27:40 +08:00
|
|
|
response = self.client.get('/nonascii_redirect/')
|
2010-03-03 03:37:48 +08:00
|
|
|
self.assertRedirects(response, self.redirect_target)
|
|
|
|
|
|
|
|
def test_permanent_nonascii_redirect(self):
|
|
|
|
"""
|
2016-10-27 15:53:39 +08:00
|
|
|
A non-ASCII argument to HttpPermanentRedirect is handled properly.
|
2010-03-03 03:37:48 +08:00
|
|
|
"""
|
2011-04-02 21:27:40 +08:00
|
|
|
response = self.client.get('/permanent_nonascii_redirect/')
|
2010-03-03 03:37:48 +08:00
|
|
|
self.assertRedirects(response, self.redirect_target, status_code=301)
|