start test implementation for contact_form

This commit is contained in:
Jan Dittberner 2015-10-12 22:07:25 +00:00
parent c5d9673ac3
commit e51d202abd
2 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,4 @@
"""
Tests for the :py:mod:`contact_form` app.
"""

View file

@ -0,0 +1,29 @@
"""
Tests for :py:mod:`contact_form.views`.
"""
from __future__ import absolute_import, unicode_literals
from django.core.urlresolvers import reverse
from django.test import TestCase
class ContactFormViewTest(TestCase):
def test_get_contact_form_template(self):
response = self.client.get(reverse('contact_form'))
self.assertTemplateUsed(response, 'contact_form/contact_form.html')
def test_get_contact_form_anonymous_status(self):
response = self.client.get(reverse('contact_form'))
self.assertEqual(response.status_code, 200)
def test_get_contact_form_anonymous_has_empty_form(self):
response = self.client.get(reverse('contact_form'))
self.assertIn('form', response.context)
self.assertEqual(len(response.context['form'].initial), 0)
def test_get_contact_form_fields_anonymous(self):
response = self.client.get(reverse('contact_form'))
for name in ('name', 'email', 'body'):
self.assertIn(name, response.context['form'].fields)