From d4c975deda4fdec018a8c546a243ff397e6de181 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 22 Jan 2016 08:23:34 +0000 Subject: [PATCH] Added tests for markdown base template --- project/common/tests.py | 20 ++++++++++++++++++++ project/common/views.py | 3 ++- templates/projects/test.md | 5 ++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/project/common/tests.py b/project/common/tests.py index ab1a5fb..ac0310d 100644 --- a/project/common/tests.py +++ b/project/common/tests.py @@ -1,6 +1,8 @@ from django.test import TestCase from django.core.urlresolvers import reverse +import os.path +PATH = os.path.dirname(os.path.abspath(__file__)) class CustomTemplateTestCase(TestCase): def setUp(self): @@ -26,3 +28,21 @@ class ReverserTestCase(TestCase): def test_invalid_reverser(self): response = self.client.post(reverse(self.REVERSER_IDENT), data={'ident': 'pages:i-dont-exist'}) self.assertEqual(response.status_code, 404) + + +class MarkdownViewTestCase(TestCase): + def test_accessable(self): + response = self.client.get(reverse('pages:projects', args=['test'])) + self.assertEqual(response.status_code, 200) + + def test_parsing(self): + response = self.client.get(reverse('pages:projects', args=['test'])) + self.assertContains(response, '

Testing

') + + def test_template_engine(self): + response = self.client.get(reverse('pages:projects', args=['test'])) + self.assertContains(response, reverse('pages:all-projects')) + + def test_invalid_template(self): + response = self.client.get(reverse('pages:projects', args=['not-a-project'])) + self.assertEqual(response.status_code, 404) diff --git a/project/common/views.py b/project/common/views.py index 00be20a..087cec0 100644 --- a/project/common/views.py +++ b/project/common/views.py @@ -1,5 +1,6 @@ from django.views.generic import TemplateView, FormView -from django.template import loader, Context, TemplateDoesNotExist +from django.template import loader, Context +from django.template.base import TemplateDoesNotExist from django.http import Http404 import markdown2 diff --git a/templates/projects/test.md b/templates/projects/test.md index ef93b24..44b2f2f 100644 --- a/templates/projects/test.md +++ b/templates/projects/test.md @@ -1 +1,4 @@ -# Test! +# Testing +This page is for testing only. + +Please [check out my other projects]({% url 'pages:all-projects' %}).