示例#1
0
 def test_redirect_to_index_if_homepage(self):
     url = reverse('pages:view', kwargs={'slug': 'test'})
     request = RequestFactory().get(url)
     mommy.make(Page, slug='test', is_homepage=True)
     view = PageDetail.as_view()
     with self.assertNumQueries(1):
         response = view(request, slug='test')
     self.assertEqual(response.status_code, 301)
     self.assertEqual(response['Location'], reverse('pages:index'))
示例#2
0
 def test_normal_page(self):
     url = reverse('pages:view', kwargs={'slug': 'test2'})
     request = RequestFactory().get(url)
     view = PageDetail.as_view()
     mommy.make(Page, slug='test2', is_homepage=False)
     with self.assertNumQueries(1):
         response = view(request, slug='test2')
     self.assertIn('Allow', response)
     self.assertIsInstance(response, TemplateResponse)
     self.assertEqual(response.status_code, 200)
     with self.assertRaises(TemplateDoesNotExist):
         response.render()