summaryrefslogtreecommitdiff
path: root/app/pages/tests/test_views.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/pages/tests/test_views.py')
-rw-r--r--app/pages/tests/test_views.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/pages/tests/test_views.py b/app/pages/tests/test_views.py
new file mode 100644
index 0000000..c771a29
--- /dev/null
+++ b/app/pages/tests/test_views.py
@@ -0,0 +1,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)