1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Changed RedirectView.permanent to False per deprecation timeline; refs #21587.

This commit is contained in:
Tim Graham
2015-01-18 16:43:57 -05:00
parent bd98926f0e
commit 6e13c0490d
8 changed files with 69 additions and 159 deletions

View File

@@ -353,27 +353,27 @@ class AssertRedirectsTests(TestCase):
"You can follow a redirect chain of multiple redirects"
response = self.client.get('/redirects/further/more/', {}, follow=True)
self.assertRedirects(response, '/no_template_view/',
status_code=301, target_status_code=200)
status_code=302, target_status_code=200)
self.assertEqual(len(response.redirect_chain), 1)
self.assertEqual(response.redirect_chain[0], ('http://testserver/no_template_view/', 301))
self.assertEqual(response.redirect_chain[0], ('http://testserver/no_template_view/', 302))
def test_multiple_redirect_chain(self):
"You can follow a redirect chain of multiple redirects"
response = self.client.get('/redirects/', {}, follow=True)
self.assertRedirects(response, '/no_template_view/',
status_code=301, target_status_code=200)
status_code=302, target_status_code=200)
self.assertEqual(len(response.redirect_chain), 3)
self.assertEqual(response.redirect_chain[0], ('http://testserver/redirects/further/', 301))
self.assertEqual(response.redirect_chain[1], ('http://testserver/redirects/further/more/', 301))
self.assertEqual(response.redirect_chain[2], ('http://testserver/no_template_view/', 301))
self.assertEqual(response.redirect_chain[0], ('http://testserver/redirects/further/', 302))
self.assertEqual(response.redirect_chain[1], ('http://testserver/redirects/further/more/', 302))
self.assertEqual(response.redirect_chain[2], ('http://testserver/no_template_view/', 302))
def test_redirect_chain_to_non_existent(self):
"You can follow a chain to a non-existent view"
response = self.client.get('/redirect_to_non_existent_view2/', {}, follow=True)
self.assertRedirects(response, '/non_existent_view/',
status_code=301, target_status_code=404)
status_code=302, target_status_code=404)
def test_redirect_chain_to_self(self):
"Redirections to self are caught and escaped"
@@ -382,7 +382,7 @@ class AssertRedirectsTests(TestCase):
response = context.exception.last_response
# The chain of redirects stops once the cycle is detected.
self.assertRedirects(response, '/redirect_to_self/',
status_code=301, target_status_code=301)
status_code=302, target_status_code=302)
self.assertEqual(len(response.redirect_chain), 2)
def test_redirect_to_self_with_changing_query(self):
@@ -397,7 +397,7 @@ class AssertRedirectsTests(TestCase):
response = context.exception.last_response
# The chain of redirects will get back to the starting point, but stop there.
self.assertRedirects(response, '/circular_redirect_2/',
status_code=301, target_status_code=301)
status_code=302, target_status_code=302)
self.assertEqual(len(response.redirect_chain), 4)
def test_redirect_chain_post(self):
@@ -405,7 +405,7 @@ class AssertRedirectsTests(TestCase):
response = self.client.post('/redirects/',
{'nothing': 'to_send'}, follow=True)
self.assertRedirects(response,
'/no_template_view/', 301, 200)
'/no_template_view/', 302, 200)
self.assertEqual(len(response.redirect_chain), 3)
def test_redirect_chain_head(self):
@@ -413,7 +413,7 @@ class AssertRedirectsTests(TestCase):
response = self.client.head('/redirects/',
{'nothing': 'to_send'}, follow=True)
self.assertRedirects(response,
'/no_template_view/', 301, 200)
'/no_template_view/', 302, 200)
self.assertEqual(len(response.redirect_chain), 3)
def test_redirect_chain_options(self):
@@ -421,7 +421,7 @@ class AssertRedirectsTests(TestCase):
response = self.client.options('/redirects/',
follow=True)
self.assertRedirects(response,
'/no_template_view/', 301, 200)
'/no_template_view/', 302, 200)
self.assertEqual(len(response.redirect_chain), 3)
def test_redirect_chain_put(self):
@@ -429,7 +429,7 @@ class AssertRedirectsTests(TestCase):
response = self.client.put('/redirects/',
follow=True)
self.assertRedirects(response,
'/no_template_view/', 301, 200)
'/no_template_view/', 302, 200)
self.assertEqual(len(response.redirect_chain), 3)
def test_redirect_chain_delete(self):
@@ -437,7 +437,7 @@ class AssertRedirectsTests(TestCase):
response = self.client.delete('/redirects/',
follow=True)
self.assertRedirects(response,
'/no_template_view/', 301, 200)
'/no_template_view/', 302, 200)
self.assertEqual(len(response.redirect_chain), 3)
def test_redirect_to_different_host(self):
@@ -445,7 +445,7 @@ class AssertRedirectsTests(TestCase):
response = self.client.get('/redirect_other_host/', follow=True)
self.assertRedirects(response,
'https://otherserver:8443/no_template_view/',
status_code=301, target_status_code=200)
status_code=302, target_status_code=200)
# We can't use is_secure() or get_host()
# because response.request is a dictionary, not an HttpRequest
self.assertEqual(response.request.get('wsgi.url_scheme'), 'https')
@@ -492,11 +492,11 @@ class AssertRedirectsTests(TestCase):
# always redirects to https
response = self.client.get('/https_redirect_view/', follow=follow, secure=secure)
# no scheme to compare too, always succeeds
self.assertRedirects(response, '/secure_view/', status_code=301)
self.assertRedirects(response, '/secure_view/', status_code=302)
# the goal scheme is https
self.assertRedirects(response, 'https://testserver/secure_view/', status_code=301)
self.assertRedirects(response, 'https://testserver/secure_view/', status_code=302)
with self.assertRaises(AssertionError):
self.assertRedirects(response, 'http://testserver/secure_view/', status_code=301)
self.assertRedirects(response, 'http://testserver/secure_view/', status_code=302)
@override_settings(ROOT_URLCONF='test_client_regress.urls')
@@ -1369,7 +1369,7 @@ class RequestHeadersTest(TestCase):
response = self.client.get("/check_headers_redirect/", follow=True, HTTP_X_ARG_CHECK='Testing 123')
self.assertEqual(response.content, b"HTTP_X_ARG_CHECK: Testing 123")
self.assertRedirects(response, '/check_headers/',
status_code=301, target_status_code=200)
status_code=302, target_status_code=200)
@override_settings(ROOT_URLCONF='test_client_regress.urls')