Example #1
0
    def test_all_live_public_pages_for_200_or_redirect_with_anonymous_user(
            self):
        """
        Test all live public pages with an anonymous user.
        Most pages should return a 200, however, the redirect
        page will return a 301 and some custom views return
        a 302. Nothing should return a 404.
        """
        if 'TRAVIS' not in os.environ:
            site = Site.objects.filter(site_name='Public')[0]
            user = AnonymousUser()
            user.client = Client()
            pages = site.root_page.get_descendants().live()
            possible = set([200, 301, 302])

            for page in pages:
                try:
                    response = user.client.get(page.url,
                                               HTTP_HOST=site.hostname)
                    self.assertEqual(response.status_code in possible,
                                     True,
                                     msg=page.url + ' returned a ' +
                                     str(response.status_code))
                except:
                    print(page.relative_url(site) + ' has a problem')
                    raise
Example #2
0
 def test_loop_page_with_anonymous_user(self):
     """
     Should redirect.
     """
     hostname = Site.objects.filter(site_name='Loop')[0].hostname
     user = AnonymousUser()
     user.client = Client()
     response = user.client.get('/groups/web-content-group/', HTTP_HOST=hostname)
     self.assertEqual(response.status_code, 302)
    def test_all_live_public_pages_for_200_or_redirect_with_anonymous_user(self):
        """
        Test all live public pages with an anonymous user. 
        Most pages should return a 200, however, the redirect 
        page will return a 301 and some custom views return
        a 302. Nothing should return a 404.
        """
        site = Site.objects.filter(site_name='Public')[0]
        user = AnonymousUser()
        user.client = Client()
        pages = site.root_page.get_descendants().live()
        possible = set([200, 301, 302])

        for page in pages:
            try:
                url = page.relative_url(site)
                response = user.client.get(page.url, HTTP_HOST=site.hostname)
                self.assertEqual(response.status_code in possible, True, msg=page.url + ' returned a ' + str(response.status_code))
            except:
                msg = page.relative_url(site) + ' has a problem'
                raise RuntimeError(msg)