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)