blob: 42a91e44b431dde20a31b4570dafb1c6ff42f5b1 (
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
28
29
|
from django.test import RequestFactory, TestCase
from mixer.backend.django import mixer
from accounts.models import User
from pages.models import Page
from pages.views import PageDetailView
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)
self.assertEqual(response.status_code, 200)
print(response.content)
|