aboutsummaryrefslogtreecommitdiff
path: root/apps/pages/tests/test_views.py
blob: c771a29384ecf5e093bab6f02db4be141dd70305 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from django.test import RequestFactory, TestCase
from django.contrib import auth

from pages.models import Page

User = auth.get_user_model()


class PageViewTest(TestCase):
    def setUp(self):
        # Every test needs access to the request factory.
        self.factory = RequestFactory()
        self.page = Page(
                title="Test Page",
                meta_description="The meta desc",
                body_markdown="the body of the page",
                )
        self.page.save()

    def test_non_existent_page(self):
        """A non-existent staticflatpage raises a 404."""
        response = self.client.get('/no_such_page/')
        self.assertEqual(response.status_code, 404)

    def test_detail_view(self):
        response = self.client.get(self.page.get_absolute_url())
        self.assertEqual(response.status_code, 200)