コード例 #1
0
 def test_410_redirect(self):
     r_410 = CMSRedirect(site=self.site, old_path='/410.php', response_code='302')
     r_410.save()
     
     c = Client()
     r = c.get('/410.php')
     self.assertEqual(r.status_code, 410)
コード例 #2
0
 def test_302_path_redirect(self):
     r_302_path = CMSRedirect(site=self.site, new_path='/', old_path='/302_path.php', response_code='302')
     r_302_path.save()
     
     c = Client()
     r = c.get('/302_path.php')
     self.assertEqual(r.status_code, 302)
     self.assertEqual(r._headers['location'][1], 'http://testserver/')
コード例 #3
0
 def test_301_page_redirect(self):
     r_301_page = CMSRedirect(site=self.site, page=self.page, old_path='/301_page.php')
     r_301_page.save()
     
     c = Client()
     r = c.get('/301_page.php')
     self.assertEqual(r.status_code, 301)
     self.assertEqual(r._headers['location'][1], 'http://testserver/')
コード例 #4
0
    def test_410_redirect(self):
        r_410 = CMSRedirect(site=self.site,
                            old_path='/410.php',
                            response_code='302')
        r_410.save()

        c = Client()
        r = c.get('/410.php')
        self.assertEqual(r.status_code, 410)
コード例 #5
0
    def test_301_path_redirect(self):
        r_301_path = CMSRedirect(site=self.site,
                                 new_path='/',
                                 old_path='/301_path.php')
        r_301_path.save()

        c = Client()
        r = c.get('/301_path.php')
        self.assertEqual(r.status_code, 301)
        self.assertEqual(r._headers['location'][1], 'http://testserver/')
コード例 #6
0
    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()

        c = Client()
        r = c.get('/302_page.php')
        self.assertEqual(r.status_code, 302)
        self.assertEqual(r._headers['location'][1], 'http://testserver/')
コード例 #7
0
    def test_redirect_can_ignore_query_string(self):
        """
        Set up a redirect as in the generic 301 page case, but then try to get this page with
        a query string appended.  Succeed nonetheless.
        """
        r_301_page = CMSRedirect(site=self.site, page=self.page, old_path='/301_page.php')
        r_301_page.save()

        c = Client()
        r = c.get('/301_page.php?this=is&a=query&string')
        self.assertEqual(r.status_code, 301)
        self.assertEqual(r._headers['location'][1], 'http://testserver')
コード例 #8
0
    def test_redirect_can_ignore_query_string(self):
        """
        Set up a redirect as in the generic 301 page case, but then try to get this page with
        a query string appended.  Succeed nonetheless.
        """
        r_301_page = CMSRedirect(site=self.site,
                                 page=self.page,
                                 old_path='/301_page.php')
        r_301_page.save()

        c = Client()
        r = c.get('/301_page.php?this=is&a=query&string')
        self.assertEqual(r.status_code, 301)
        self.assertEqual(r._headers['location'][1], 'http://testserver')
コード例 #9
0
 def test_cms_redirect_no_page_no_new_path(self):
     """Should return the HttpResponseGone class."""
     cmsredirect = CMSRedirect()
     result = self.middleware.cms_redirect(cmsredirect, {})
     self.assertTrue(isinstance(result, http.HttpResponseGone))
コード例 #10
0
 def test_get_cms_redirect_response_class_302(self):
     """Should return the HttpResponseRedirect class."""
     cmsredirect = CMSRedirect(response_code='302')
     result = self.middleware.get_cms_redirect_response_class(cmsredirect)
     self.assertEqual(result, http.HttpResponseRedirect)