29 lines
1 KiB
Python
29 lines
1 KiB
Python
"""
|
|
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)
|