summaryrefslogtreecommitdiff
path: root/tests/regressiontests/comment_tests/tests/__init__.py
blob: f80b29e17b8553650ae8a6ba148968ff962c48ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from __future__ import absolute_import

from django.contrib.auth.models import User
from django.contrib.comments.forms import CommentForm
from django.contrib.comments.models import Comment
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.test import TestCase
from django.test.utils import override_settings

from ..models import Article, Author

# Shortcut
CT = ContentType.objects.get_for_model

# Helper base class for comment tests that need data.
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.UnsaltedMD5PasswordHasher',))
class CommentTestCase(TestCase):
    fixtures = ["comment_tests"]
    urls = 'regressiontests.comment_tests.urls_default'

    def createSomeComments(self):
        # Two anonymous comments on two different objects
        c1 = Comment.objects.create(
            content_type = CT(Article),
            object_pk = "1",
            user_name = "Joe Somebody",
            user_email = "jsomebody@example.com",
            user_url = "http://example.com/~joe/",
            comment = "First!",
            site = Site.objects.get_current(),
        )
        c2 = Comment.objects.create(
            content_type = CT(Author),
            object_pk = "1",
            user_name = "Joe Somebody",
            user_email = "jsomebody@example.com",
            user_url = "http://example.com/~joe/",
            comment = "First here, too!",
            site = Site.objects.get_current(),
        )

        # Two authenticated comments: one on the same Article, and
        # one on a different Author
        user = User.objects.create(
            username = "frank_nobody",
            first_name = "Frank",
            last_name = "Nobody",
            email = "fnobody@example.com",
            password = "",
            is_staff = False,
            is_active = True,
            is_superuser = False,
        )
        c3 = Comment.objects.create(
            content_type = CT(Article),
            object_pk = "1",
            user = user,
            user_url = "http://example.com/~frank/",
            comment = "Damn, I wanted to be first.",
            site = Site.objects.get_current(),
        )
        c4 = Comment.objects.create(
            content_type = CT(Author),
            object_pk = "2",
            user = user,
            user_url = "http://example.com/~frank/",
            comment = "You get here first, too?",
            site = Site.objects.get_current(),
        )

        return c1, c2, c3, c4

    def getData(self):
        return {
            'name'      : 'Jim Bob',
            'email'     : 'jim.bob@example.com',
            'url'       : '',
            'comment'   : 'This is my comment',
        }

    def getValidData(self, obj):
        f = CommentForm(obj)
        d = self.getData()
        d.update(f.initial)
        return d

from regressiontests.comment_tests.tests.app_api_tests import *
from regressiontests.comment_tests.tests.feed_tests import *
from regressiontests.comment_tests.tests.model_tests import *
from regressiontests.comment_tests.tests.comment_form_tests import *
from regressiontests.comment_tests.tests.templatetag_tests import *
from regressiontests.comment_tests.tests.comment_view_tests import *
from regressiontests.comment_tests.tests.moderation_view_tests import *
from regressiontests.comment_tests.tests.comment_utils_moderators_tests import *