Skip to content

Commit

Permalink
use skipIfCustomUser decorator for tests which needs to create users
Browse files Browse the repository at this point in the history
  • Loading branch information
Fantomas42 committed Apr 1, 2013
1 parent 57f6403 commit f795daa
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions zinnia/tests/admin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""Test cases for Zinnia's admin"""
from django.test import TestCase
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia import settings
from zinnia.models.entry import Entry
from zinnia.models.author import Author
from zinnia.models.category import Category


@skipIfCustomUser
class EntryAdminTestCase(TestCase):
"""Test case for Entry Admin"""
urls = 'zinnia.tests.urls'
Expand Down Expand Up @@ -53,6 +55,7 @@ def test_entry_add_and_change(self):
self.assertEquals(Entry.objects.count(), 1)


@skipIfCustomUser
class CategoryAdminTestCase(TestCase):
"""Test cases for Category Admin"""
urls = 'zinnia.tests.urls'
Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/admin_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.utils.translation import activate
from django.utils.translation import deactivate
from django.contrib.admin.views.main import ChangeList
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia.models.entry import Entry
from zinnia.models.author import Author
Expand All @@ -24,6 +25,7 @@ class MiniEntryCategoryAdmin(ModelAdmin):
list_filter = [CategoryListFilter]


@skipIfCustomUser
class AuthorListFilterTestCase(TestCase):
"""Test case for AuthorListFilter"""
urls = 'zinnia.tests.urls'
Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/author.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""Test cases for Zinnia's Author"""
from django.test import TestCase
from django.contrib.sites.models import Site
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia.models.entry import Entry
from zinnia.models.author import Author
from zinnia.managers import PUBLISHED


@skipIfCustomUser
class AuthorTestCase(TestCase):

def setUp(self):
Expand Down
4 changes: 3 additions & 1 deletion zinnia/tests/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.utils.translation import activate
from django.utils.translation import deactivate
from django.contrib.comments.models import CommentFlag
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia.models import entry
from zinnia.models.entry import Entry
Expand All @@ -30,6 +31,7 @@ def setUp(self):
'slug': 'my-entry'}
self.entry = Entry.objects.create(**params)

@skipIfCustomUser
def test_discussions(self):
site = Site.objects.get_current()
self.assertEquals(self.entry.discussions.count(), 0)
Expand All @@ -54,7 +56,7 @@ def test_discussions(self):
self.assertEquals(self.entry.trackbacks.count(), 0)

author = Author.objects.create_user(username='webmaster',
email='webmaster@example.com')
email='webmaster@example.com')

comment = comments.get_model().objects.create(
comment='My Comment 3',
Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.utils.feedgenerator import DefaultFeed
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.tests.utils import skipIfCustomUser

from tagging.models import Tag

Expand All @@ -34,6 +35,7 @@
from zinnia.feeds import LatestDiscussions


@skipIfCustomUser
class ZinniaFeedsTestCase(TestCase):
"""Test cases for the Feed classes provided"""
urls = 'zinnia.tests.urls'
Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/flags.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Test cases for Zinnia's flags"""
from django.test import TestCase
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia import flags
from zinnia.flags import get_user_flagger
from zinnia.flags import _get_user_flagger


@skipIfCustomUser
class FlagsTestCase(TestCase):
"""Test cases for zinnia.flags"""

Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/long_enough.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
from django.test import TestCase
from django.contrib import comments
from django.contrib.sites.models import Site
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia.models.entry import Entry
from zinnia.models.author import Author
from zinnia.managers import PUBLISHED
from zinnia.spam_checker.backends.long_enough import backend


@skipIfCustomUser
class LongEnoughTestCase(TestCase):
"""Test cases for zinnia.spam_checker.long_enough"""

Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/managers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test cases for Zinnia's managers"""
from django.test import TestCase
from django.contrib.sites.models import Site
from django.contrib.auth.tests.utils import skipIfCustomUser

from tagging.models import Tag

Expand All @@ -13,6 +14,7 @@
from zinnia.managers import entries_published


@skipIfCustomUser
class ManagersTestCase(TestCase):

def setUp(self):
Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/metaweblog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.test import TestCase
from django.contrib.sites.models import Site
from django.core.files.storage import default_storage
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia.models.entry import Entry
from zinnia.models.author import Author
Expand All @@ -20,6 +21,7 @@
from zinnia.tests.utils import TestTransport


@skipIfCustomUser
class MetaWeblogTestCase(TestCase):
"""Test cases for MetaWeblog"""
urls = 'zinnia.tests.urls'
Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.test import TestCase
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia.models.entry import Entry
from zinnia.models.author import Author
Expand Down Expand Up @@ -286,6 +287,7 @@ def test_prefetch_related_mixin(self):
self.assertRaises(ImproperlyConfigured,
instance.get_queryset)

@skipIfCustomUser
def test_prefetch_categories_authors_mixin(self):
author = Author.objects.create_user(username='author',
email='author@example.com')
Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/moderator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.core.urlresolvers import reverse
from django.contrib.comments.forms import CommentForm
from django.contrib.comments.moderation import moderator as moderator_stack
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia.models.entry import Entry
from zinnia.models.author import Author
Expand All @@ -15,6 +16,7 @@
from zinnia.signals import disconnect_discussion_signals


@skipIfCustomUser
class EntryCommentModeratorTestCase(TestCase):
"""Test cases for the moderator"""

Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/pingback.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.test.utils import restore_template_loaders
from django.test.utils import setup_test_template_loader
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.tests.utils import skipIfCustomUser

from BeautifulSoup import BeautifulSoup

Expand All @@ -26,6 +27,7 @@
from zinnia.signals import disconnect_discussion_signals


@skipIfCustomUser
class PingBackTestCase(TestCase):
"""Test cases for pingbacks"""
urls = 'zinnia.tests.urls'
Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/quick_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
from django.test import TestCase
from django.test.utils import restore_template_loaders
from django.test.utils import setup_test_template_loader
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia import settings
from zinnia.models.entry import Entry
from zinnia.models.author import Author
from zinnia.managers import DRAFT


@skipIfCustomUser
class QuickEntryTestCase(TestCase):
"""Test cases for quick_entry view"""
urls = 'zinnia.tests.urls'
Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/sitemaps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test cases for Zinnia's sitemaps"""
from django.test import TestCase
from django.contrib.sites.models import Site
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia.managers import PUBLISHED
from zinnia.models.entry import Entry
Expand All @@ -12,6 +13,7 @@
from zinnia.sitemaps import TagSitemap


@skipIfCustomUser
class ZinniaSitemapsTestCase(TestCase):
"""Test cases for Sitemaps classes provided"""
urls = 'zinnia.tests.urls'
Expand Down
7 changes: 7 additions & 0 deletions zinnia/tests/templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from django.core.urlresolvers import reverse
from django.contrib.sites.models import Site
from django.contrib.comments.models import CommentFlag
from django.contrib.auth.tests.utils import skipIfCustomUser

from tagging.models import Tag

from zinnia.models.entry import Entry
Expand Down Expand Up @@ -93,6 +95,7 @@ def test_get_categories_tree(self):
self.assertEquals(context['template'], 'custom_template.html')
self.assertEquals(context['context_category'], category)

@skipIfCustomUser
def test_get_authors(self):
source_context = Context({})
with self.assertNumQueries(1):
Expand Down Expand Up @@ -345,6 +348,7 @@ def test_get_calendar_entries(self):
self.assertEquals(context['previous_month'], datetime(2010, 1, 1))
self.assertEquals(context['next_month'], None)

@skipIfCustomUser
def test_get_recent_comments(self):
site = Site.objects.get_current()
with self.assertNumQueries(1):
Expand Down Expand Up @@ -384,6 +388,7 @@ def test_get_recent_comments(self):
self.assertEquals(context['comments'][1].content_object,
self.entry)

@skipIfCustomUser
def test_get_recent_linkbacks(self):
user = Author.objects.create_user(username='webmaster',
email='webmaster@example.com')
Expand Down Expand Up @@ -523,6 +528,7 @@ def __init__(self, get_dict):
self.assertEquals(context['middle'], [])
self.assertEquals(context['end'], [5, 6, 7])

@skipIfCustomUser
def test_zinnia_breadcrumbs(self):
class FakeRequest(object):
def __init__(self, path):
Expand Down Expand Up @@ -703,6 +709,7 @@ def test_get_tag_cloud(self):
self.assertEquals(context['template'], 'custom_template.html')
self.assertEquals(context['context_tag'], tag)

@skipIfCustomUser
def test_zinnia_statistics(self):
with self.assertNumQueries(9):
context = zinnia_statistics()
Expand Down
2 changes: 2 additions & 0 deletions zinnia/tests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.signals import user_logged_in
from django.contrib.auth.models import update_last_login
from django.contrib.auth.tests.utils import skipIfCustomUser

from zinnia.models.entry import Entry
from zinnia.models.author import Author
Expand All @@ -23,6 +24,7 @@
from zinnia.signals import disconnect_discussion_signals


@skipIfCustomUser
class ViewsBaseCase(TestCase):
"""
Setup and utility function base case.
Expand Down

0 comments on commit f795daa

Please sign in to comment.