Skip to content

Commit

Permalink
improve tests for integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Fantomas42 committed Jul 14, 2012
1 parent f4e2451 commit 05f622b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions zinnia/tests/quick_entry.py
Expand Up @@ -2,6 +2,8 @@
"""Test cases for Zinnia's quick entry"""
from django.test import TestCase
from django.contrib.auth.models import User
from django.test.utils import restore_template_loaders
from django.test.utils import setup_test_template_loader

from zinnia import settings
from zinnia.models import Entry
Expand All @@ -13,13 +15,19 @@ class QuickEntryTestCase(TestCase):
urls = 'zinnia.tests.urls'

def setUp(self):
setup_test_template_loader(
{'404.html': '',
'admin/change_form.html': '',
'zinnia/entry_detail.html': ''})

self.original_wysiwyg = settings.WYSIWYG
settings.WYSIWYG = None
User.objects.create_user('user', 'user@example.com', 'password')
User.objects.create_superuser('admin', 'admin@example.com', 'password')

def tearDown(self):
settings.WYSIWYG = self.original_wysiwyg
restore_template_loaders()

def test_quick_entry(self):
response = self.client.get('/quick_entry/', follow=True)
Expand Down
13 changes: 9 additions & 4 deletions zinnia/tests/views.py
Expand Up @@ -150,24 +150,26 @@ def test_zinnia_entry_archive_week(self):

def test_zinnia_entry_archive_month(self):
setup_test_template_loader(
{'zinnia/archives/2010/month/01/entry_archive_month.html': ''})
{'zinnia/archives/2010/month/01/entry_archive_month.html': '',
'zinnia/entry_archive_month.html': ''})
response = self.check_publishing_context(
'/2010/01/', 1, 2, 'entry_list', 4)
self.assertTemplateUsed(
response, 'zinnia/archives/2010/month/01/entry_archive_month.html')
self.assertEquals(response.context['previous_month'], None)
self.assertEquals(response.context['next_month'], date(2010, 6, 1))
restore_template_loaders()
response = self.client.get('/2010/06/')
self.assertEquals(response.context['previous_month'], date(2010, 1, 1))
self.assertEquals(response.context['next_month'], None)
response = self.client.get('/2009/12/')
self.assertEquals(response.context['previous_month'], None)
self.assertEquals(response.context['next_month'], date(2010, 1, 1))
restore_template_loaders()

def test_zinnia_entry_archive_day(self):
setup_test_template_loader(
{'zinnia/archives/2010/01/01/entry_archive_day.html': ''})
{'zinnia/archives/2010/01/01/entry_archive_day.html': '',
'zinnia/entry_archive_day.html': ''})
response = self.check_publishing_context(
'/2010/01/01/', 1, 2, 'entry_list', 5)
self.assertTemplateUsed(
Expand All @@ -176,12 +178,12 @@ def test_zinnia_entry_archive_day(self):
self.assertEquals(response.context['next_month'], date(2010, 6, 1))
self.assertEquals(response.context['previous_day'], None)
self.assertEquals(response.context['next_day'], date(2010, 6, 1))
restore_template_loaders()
response = self.client.get('/2010/06/01/')
self.assertEquals(response.context['previous_month'], date(2010, 1, 1))
self.assertEquals(response.context['next_month'], None)
self.assertEquals(response.context['previous_day'], date(2010, 1, 1))
self.assertEquals(response.context['next_day'], None)
restore_template_loaders()

def test_zinnia_entry_archive_today(self):
setup_test_template_loader(
Expand Down Expand Up @@ -422,8 +424,11 @@ def test_zinnia_sitemap(self):
restore_template_loaders()

def test_zinnia_trackback(self):
setup_test_template_loader(
{'404.html': ''})
response = self.client.post('/trackback/404/')
self.assertEquals(response.status_code, 404)
restore_template_loaders()
self.assertEquals(
self.client.post('/trackback/1/').status_code, 301)
self.assertEquals(
Expand Down

0 comments on commit 05f622b

Please sign in to comment.