/tests/regressiontests/views/tests/specials.py
Python | 35 lines | 12 code | 5 blank | 18 comment | 0 complexity | 7cb1a1d1299e6b0ab52524e0f900b18f MD5 | raw file
1# coding: utf-8 2from django.test import TestCase 3 4class URLHandling(TestCase): 5 """ 6 Tests for URL handling in views and responses. 7 """ 8 redirect_target = "/views/%E4%B8%AD%E6%96%87/target/" 9 10 def test_combining_redirect(self): 11 """ 12 Tests that redirecting to an IRI, requiring encoding before we use it 13 in an HTTP response, is handled correctly. In this case the arg to 14 HttpRedirect is ASCII but the current request path contains non-ASCII 15 characters so this test ensures the creation of the full path with a 16 base non-ASCII part is handled correctly. 17 """ 18 response = self.client.get(u'/views/ä¸?–‡/') 19 self.assertRedirects(response, self.redirect_target) 20 21 def test_nonascii_redirect(self): 22 """ 23 Tests that a non-ASCII argument to HttpRedirect is handled properly. 24 """ 25 response = self.client.get('/views/nonascii_redirect/') 26 self.assertRedirects(response, self.redirect_target) 27 28 def test_permanent_nonascii_redirect(self): 29 """ 30 Tests that a non-ASCII argument to HttpPermanentRedirect is handled 31 properly. 32 """ 33 response = self.client.get('/views/permanent_nonascii_redirect/') 34 self.assertRedirects(response, self.redirect_target, status_code=301) 35