Permalink
Browse files

improve tests for integration

  • Loading branch information...
Fantomas42 committed Jul 14, 2012
1 parent f4e2451 commit 05f622b8353abb7470642d0e93e6aead6fd272cb
Showing with 17 additions and 4 deletions.
  1. +8 −0 zinnia/tests/quick_entry.py
  2. +9 −4 zinnia/tests/views.py
@@ -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
@@ -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)
View
@@ -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(
@@ -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(
@@ -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(

0 comments on commit 05f622b

Please sign in to comment.