1
from django.contrib.comments.models import Comment
2
from regressiontests.comment_tests.models import Author, Article
3
from regressiontests.comment_tests.tests import CommentTestCase
5
class CommentModelTests(CommentTestCase):
8
for c in self.createSomeComments():
9
self.failIfEqual(c.submit_date, None)
11
def testUserProperties(self):
12
c1, c2, c3, c4 = self.createSomeComments()
13
self.assertEqual(c1.name, "Joe Somebody")
14
self.assertEqual(c2.email, "jsomebody@example.com")
15
self.assertEqual(c3.name, "Frank Nobody")
16
self.assertEqual(c3.url, "http://example.com/~frank/")
17
self.assertEqual(c1.user, None)
18
self.assertEqual(c3.user, c4.user)
20
class CommentManagerTests(CommentTestCase):
22
def testInModeration(self):
23
"""Comments that aren't public are considered in moderation"""
24
c1, c2, c3, c4 = self.createSomeComments()
29
moderated_comments = list(Comment.objects.in_moderation().order_by("id"))
30
self.assertEqual(moderated_comments, [c1, c2])
32
def testRemovedCommentsNotInModeration(self):
33
"""Removed comments are not considered in moderation"""
34
c1, c2, c3, c4 = self.createSomeComments()
40
moderated_comments = list(Comment.objects.in_moderation())
41
self.assertEqual(moderated_comments, [c1])
43
def testForModel(self):
44
c1, c2, c3, c4 = self.createSomeComments()
45
article_comments = list(Comment.objects.for_model(Article).order_by("id"))
46
author_comments = list(Comment.objects.for_model(Author.objects.get(pk=1)))
47
self.assertEqual(article_comments, [c1, c3])
48
self.assertEqual(author_comments, [c2])