~ubuntu-branches/ubuntu/quantal/python-django/quantal

« back to all changes in this revision

Viewing changes to tests/regressiontests/comment_tests/tests/model_tests.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2008-11-15 19:15:33 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20081115191533-xbt1ut2xf4fvwtvc
Tags: 1.0.1-0ubuntu1
* New upstream release:
  - Bug fixes.

* The tests/ sub-directory appaers to have been dropped upstream, so pull
  our patch to workaround the tests and modify the rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
4
 
 
5
 
class CommentModelTests(CommentTestCase):
6
 
 
7
 
    def testSave(self):
8
 
        for c in self.createSomeComments():
9
 
            self.failIfEqual(c.submit_date, None)
10
 
 
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)
19
 
 
20
 
class CommentManagerTests(CommentTestCase):
21
 
 
22
 
    def testInModeration(self):
23
 
        """Comments that aren't public are considered in moderation"""
24
 
        c1, c2, c3, c4 = self.createSomeComments()
25
 
        c1.is_public = False
26
 
        c2.is_public = False
27
 
        c1.save()
28
 
        c2.save()
29
 
        moderated_comments = list(Comment.objects.in_moderation().order_by("id"))
30
 
        self.assertEqual(moderated_comments, [c1, c2])
31
 
 
32
 
    def testRemovedCommentsNotInModeration(self):
33
 
        """Removed comments are not considered in moderation"""
34
 
        c1, c2, c3, c4 = self.createSomeComments()
35
 
        c1.is_public = False
36
 
        c2.is_public = False
37
 
        c2.is_removed = True
38
 
        c1.save()
39
 
        c2.save()
40
 
        moderated_comments = list(Comment.objects.in_moderation())
41
 
        self.assertEqual(moderated_comments, [c1])
42
 
 
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])