def test_child_page(self): request = MockRequest(self.user, has_otp=True, has_sudo=True) page = models.HelpBasePage.objects.filter(parent__isnull=False).get() response = views.index(request, page_pk=page.pk) self.assertEqual(response.status_code, 200) self.assertEqual(response.context_data["page"], page) breadcrumbs = [p for p in response.context_data["breadcrumbs"]] self.assertEqual(breadcrumbs, [page.parent, page])
def test_index(self): request = MockRequest(self.user, has_otp=True, has_sudo=True) response = views.index(request) self.assertEqual(response.status_code, 200) expected_page = models.HelpBasePage.objects.filter(parent__isnull=True).get() self.assertEqual(response.context_data["page"], expected_page) breadcrumbs = [p for p in response.context_data["breadcrumbs"]] self.assertEqual(breadcrumbs, [expected_page]) # with root page as kwarg response = views.index(request, page_pk=expected_page.pk) self.assertEqual(response.status_code, 200) self.assertEqual(response.context_data["page"], expected_page) breadcrumbs = [p for p in response.context_data["breadcrumbs"]] self.assertEqual(breadcrumbs, [expected_page])
def test_index(self): request = MockRequest(self.user, has_otp=True, has_sudo=True) response = views.index(request) self.assertEqual(response.status_code, 200) expected_page = models.HelpBasePage.objects.filter( parent__isnull=True).get() self.assertEqual(response.context_data["page"], expected_page) breadcrumbs = [p for p in response.context_data["breadcrumbs"]] self.assertEqual(breadcrumbs, [expected_page]) # with root page as kwarg response = views.index(request, page_pk=expected_page.pk) self.assertEqual(response.status_code, 200) self.assertEqual(response.context_data["page"], expected_page) breadcrumbs = [p for p in response.context_data["breadcrumbs"]] self.assertEqual(breadcrumbs, [expected_page])
def test_404(self): request = MockRequest(self.user, has_otp=True, has_sudo=True) with self.assertRaises(Http404): views.index(request, page_pk="123")