Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated the unit tests so that they fail when they should fail

  • Loading branch information...
commit f5f2072574e4173b52486edb2718c4b69298442c 1 parent b9b3cac
@MegaMark16 MegaMark16 authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 cms_redirects/tests.py
View
12 cms_redirects/tests.py
@@ -1,10 +1,12 @@
import unittest
+
from django.test.client import Client
-from cms.models import Page, Title
from django.contrib.sites.models import Site
-from cms_redirects.models import CMSRedirect
from django.conf import settings
+from cms.models import Page, Title
+from cms_redirects.models import CMSRedirect
+
class TestRedirects(unittest.TestCase):
def setUp(self):
settings.APPEND_SLASH = False
@@ -29,7 +31,8 @@ def test_301_page_redirect(self):
c = Client()
r = c.get('/301_page.php')
self.assertEqual(r.status_code, 301)
-
+ self.assertEqual(r._headers['location'][1], 'http://testserver/')
+
def test_302_page_redirect(self):
r_302_page = CMSRedirect(site=self.site, page=self.page, old_path='/302_page.php', response_code='302')
r_302_page.save()
@@ -37,6 +40,7 @@ def test_302_page_redirect(self):
c = Client()
r = c.get('/302_page.php')
self.assertEqual(r.status_code, 302)
+ self.assertEqual(r._headers['location'][1], 'http://testserver/')
def test_301_path_redirect(self):
r_301_path = CMSRedirect(site=self.site, new_path='/', old_path='/301_path.php')
@@ -45,6 +49,7 @@ def test_301_path_redirect(self):
c = Client()
r = c.get('/301_path.php')
self.assertEqual(r.status_code, 301)
+ self.assertEqual(r._headers['location'][1], 'http://testserver/')
def test_302_path_redirect(self):
r_302_path = CMSRedirect(site=self.site, new_path='/', old_path='/302_path.php', response_code='302')
@@ -53,6 +58,7 @@ def test_302_path_redirect(self):
c = Client()
r = c.get('/302_path.php')
self.assertEqual(r.status_code, 302)
+ self.assertEqual(r._headers['location'][1], 'http://testserver/')
def test_410_redirect(self):
r_410 = CMSRedirect(site=self.site, old_path='/410.php', response_code='302')
Please sign in to comment.
Something went wrong with that request. Please try again.