|
@@ -22,8 +22,11 @@ rather than the HTML rendered to the end-user.
|
|
|
"""
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
+import warnings
|
|
|
+
|
|
|
from django.core import mail
|
|
|
from django.http import HttpResponse
|
|
|
+from django.utils.deprecation import RemovedInDjango19Warning
|
|
|
from django.test import Client, TestCase, RequestFactory
|
|
|
from django.test import override_settings
|
|
|
|
|
@@ -174,14 +177,18 @@ class ClientTest(TestCase):
|
|
|
|
|
|
def test_permanent_redirect(self):
|
|
|
"GET a URL that redirects permanently elsewhere"
|
|
|
- response = self.client.get('/permanent_redirect_view/')
|
|
|
- # Check that the response was a 301 (permanent redirect)
|
|
|
- self.assertRedirects(response, 'http://testserver/get_view/', status_code=301)
|
|
|
-
|
|
|
- client_providing_host = Client(HTTP_HOST='django.testserver')
|
|
|
- response = client_providing_host.get('/permanent_redirect_view/')
|
|
|
- # Check that the response was a 301 (permanent redirect) with absolute URI
|
|
|
- self.assertRedirects(response, 'http://django.testserver/get_view/', status_code=301)
|
|
|
+ with warnings.catch_warnings():
|
|
|
+ warnings.simplefilter("ignore", RemovedInDjango19Warning)
|
|
|
+ response = self.client.get('/permanent_redirect_view/')
|
|
|
+ # Check that the response was a 301 (permanent redirect)
|
|
|
+ self.assertRedirects(response, 'http://testserver/get_view/', status_code=301)
|
|
|
+
|
|
|
+ with warnings.catch_warnings():
|
|
|
+ warnings.simplefilter("ignore", RemovedInDjango19Warning)
|
|
|
+ client_providing_host = Client(HTTP_HOST='django.testserver')
|
|
|
+ response = client_providing_host.get('/permanent_redirect_view/')
|
|
|
+ # Check that the response was a 301 (permanent redirect) with absolute URI
|
|
|
+ self.assertRedirects(response, 'http://django.testserver/get_view/', status_code=301)
|
|
|
|
|
|
def test_temporary_redirect(self):
|
|
|
"GET a URL that does a non-permanent redirect"
|
|
@@ -191,26 +198,34 @@ class ClientTest(TestCase):
|
|
|
|
|
|
def test_redirect_to_strange_location(self):
|
|
|
"GET a URL that redirects to a non-200 page"
|
|
|
- response = self.client.get('/double_redirect_view/')
|
|
|
+ with warnings.catch_warnings():
|
|
|
+ warnings.simplefilter("ignore", RemovedInDjango19Warning)
|
|
|
+ response = self.client.get('/double_redirect_view/')
|
|
|
|
|
|
- # Check that the response was a 302, and that
|
|
|
- # the attempt to get the redirection location returned 301 when retrieved
|
|
|
- self.assertRedirects(response, 'http://testserver/permanent_redirect_view/', target_status_code=301)
|
|
|
+ # Check that the response was a 302, and that
|
|
|
+ # the attempt to get the redirection location returned 301 when retrieved
|
|
|
+ self.assertRedirects(response, 'http://testserver/permanent_redirect_view/', target_status_code=301)
|
|
|
|
|
|
def test_follow_redirect(self):
|
|
|
"A URL that redirects can be followed to termination."
|
|
|
- response = self.client.get('/double_redirect_view/', follow=True)
|
|
|
- self.assertRedirects(response, 'http://testserver/get_view/', status_code=302, target_status_code=200)
|
|
|
+ with warnings.catch_warnings():
|
|
|
+ warnings.simplefilter("ignore", RemovedInDjango19Warning)
|
|
|
+ response = self.client.get('/double_redirect_view/', follow=True)
|
|
|
+ self.assertRedirects(response, 'http://testserver/get_view/', status_code=302, target_status_code=200)
|
|
|
self.assertEqual(len(response.redirect_chain), 2)
|
|
|
|
|
|
def test_redirect_http(self):
|
|
|
"GET a URL that redirects to an http URI"
|
|
|
- response = self.client.get('/http_redirect_view/', follow=True)
|
|
|
+ with warnings.catch_warnings():
|
|
|
+ warnings.simplefilter("ignore", RemovedInDjango19Warning)
|
|
|
+ response = self.client.get('/http_redirect_view/', follow=True)
|
|
|
self.assertFalse(response.test_was_secure_request)
|
|
|
|
|
|
def test_redirect_https(self):
|
|
|
"GET a URL that redirects to an https URI"
|
|
|
- response = self.client.get('/https_redirect_view/', follow=True)
|
|
|
+ with warnings.catch_warnings():
|
|
|
+ warnings.simplefilter("ignore", RemovedInDjango19Warning)
|
|
|
+ response = self.client.get('/https_redirect_view/', follow=True)
|
|
|
self.assertTrue(response.test_was_secure_request)
|
|
|
|
|
|
def test_notfound_response(self):
|