Example #1
0
    def test_create_page_post(self):
        request = MockRequest(self.user, has_otp=True, has_sudo=True)
        request.method = "POST"
        request.POST = {"title": "Test Page", "slug": "test-page"}

        page = models.HelpBasePage.objects.filter(parent__isnull=True).get()
        response = views.create_page(request, "helppage", page.pk)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(models.HelpPage.objects.count(), 0)

        request.POST["body"] = "body"
        response = views.create_page(request, "helppage", page.pk)
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response["Location"], reverse("admin:index", kwargs={"page_pk": page.pk}))

        new_page = models.HelpBasePage.objects.get(slug="test-page", parent_id=page.pk)
        self.assertEqual(new_page.specific_class, models.HelpPage)
Example #2
0
    def test_create_page_post(self):
        request = MockRequest(self.user, has_otp=True, has_sudo=True)
        request.method = "POST"
        request.POST = {"title": "Test Page", "slug": "test-page"}

        page = models.HelpBasePage.objects.filter(parent__isnull=True).get()
        response = views.create_page(request, "helppage", page.pk)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(models.HelpPage.objects.count(), 0)

        request.POST["body"] = "body"
        response = views.create_page(request, "helppage", page.pk)
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response["Location"],
                         reverse("admin:index", kwargs={"page_pk": page.pk}))

        new_page = models.HelpBasePage.objects.get(slug="test-page",
                                                   parent_id=page.pk)
        self.assertEqual(new_page.specific_class, models.HelpPage)
Example #3
0
    def test_404(self):
        request = MockRequest(self.user, has_otp=True, has_sudo=True)
        page = models.HelpBasePage.objects.filter(parent__isnull=True).get()

        with self.assertRaises(Http404):
            views.create_page(request, "helppage", 123)

        with self.assertRaises(Http404):
            views.create_page(request, "notpage", page.pk)

        with self.assertRaises(Http404):
            views.create_page(request, "notpage", 123)
Example #4
0
    def test_404(self):
        request = MockRequest(self.user, has_otp=True, has_sudo=True)
        page = models.HelpBasePage.objects.filter(parent__isnull=True).get()

        with self.assertRaises(Http404):
            views.create_page(request, "helppage", 123)

        with self.assertRaises(Http404):
            views.create_page(request, "notpage", page.pk)

        with self.assertRaises(Http404):
            views.create_page(request, "notpage", 123)
Example #5
0
    def test_create_page_get(self):
        request = MockRequest(self.user, has_otp=True, has_sudo=True)

        page = models.HelpBasePage.objects.filter(parent__isnull=True).get()
        response = views.create_page(request, "helppage", page.pk)
        self.assertEqual(response.status_code, 200)
Example #6
0
    def test_create_page_get(self):
        request = MockRequest(self.user, has_otp=True, has_sudo=True)

        page = models.HelpBasePage.objects.filter(parent__isnull=True).get()
        response = views.create_page(request, "helppage", page.pk)
        self.assertEqual(response.status_code, 200)