示例#1
0
    def test_edit_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=False).get()

        response = views.edit_page(request, page_pk=page.pk)
        self.assertEqual(response.status_code, 200)

        request.POST["app"] = "tickets.urls"
        response = views.edit_page(request, page_pk=page.pk)
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response["Location"], reverse("admin:index", kwargs={"page_pk": page.pk}))

        page.refresh_from_db()
        self.assertEqual(page.title, "Test Page")
        self.assertEqual(page.slug, "test-page")
示例#2
0
    def test_edit_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=False).get()

        response = views.edit_page(request, page_pk=page.pk)
        self.assertEqual(response.status_code, 200)

        request.POST["app"] = "tickets.urls"
        response = views.edit_page(request, page_pk=page.pk)
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response["Location"],
                         reverse("admin:index", kwargs={"page_pk": page.pk}))

        page.refresh_from_db()
        self.assertEqual(page.title, "Test Page")
        self.assertEqual(page.slug, "test-page")
示例#3
0
    def test_has_no_preview(self):
        request = MockRequest(self.user, has_otp=True, has_sudo=True)
        base_page = models.HelpBasePage.objects.filter(
            parent__isnull=False).get()
        ct = ContentType.objects.get(model="helppage", app_label="cms")
        page = models.HelpPage.objects.create(parent=base_page,
                                              title="FAQ",
                                              body="",
                                              content_type=ct)

        response = views.edit_page(request, page_pk=page.pk)
        self.assertEqual(response.status_code, 200)
        response.render()
        self.assertInHTML("<div class=\"panel-heading\">Preview</div>",
                          response.content.decode(),
                          count=0)
示例#4
0
    def test_404(self):
        request = MockRequest(self.user, has_otp=True, has_sudo=True)

        with self.assertRaises(Http404):
            views.edit_page(request, page_pk="123")
示例#5
0
    def test_edit_page_get(self):
        request = MockRequest(self.user, has_otp=True, has_sudo=True)
        page = models.HelpBasePage.objects.filter(parent__isnull=False).get()

        response = views.edit_page(request, page_pk=page.pk)
        self.assertEqual(response.status_code, 200)
示例#6
0
    def test_404(self):
        request = MockRequest(self.user, has_otp=True, has_sudo=True)

        with self.assertRaises(Http404):
            views.edit_page(request, page_pk="123")
示例#7
0
    def test_edit_page_get(self):
        request = MockRequest(self.user, has_otp=True, has_sudo=True)
        page = models.HelpBasePage.objects.filter(parent__isnull=False).get()

        response = views.edit_page(request, page_pk=page.pk)
        self.assertEqual(response.status_code, 200)