~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-07-29 11:26:28 UTC
  • mfrom: (1.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20090729112628-9qrzwnl9x32jxhbg
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from django.conf import settings
 
2
from django.contrib import comments
 
3
from django.contrib.comments.models import Comment
 
4
from django.contrib.comments.forms import CommentForm
 
5
from regressiontests.comment_tests.tests import CommentTestCase
 
6
 
 
7
class CommentAppAPITests(CommentTestCase):
 
8
    """Tests for the "comment app" API"""
 
9
 
 
10
    def testGetCommentApp(self):
 
11
        self.assertEqual(comments.get_comment_app(), comments)
 
12
 
 
13
    def testGetForm(self):
 
14
        self.assertEqual(comments.get_form(), CommentForm)
 
15
 
 
16
    def testGetFormTarget(self):
 
17
        self.assertEqual(comments.get_form_target(), "/post/")
 
18
 
 
19
    def testGetFlagURL(self):
 
20
        c = Comment(id=12345)
 
21
        self.assertEqual(comments.get_flag_url(c), "/flag/12345/")
 
22
 
 
23
    def getGetDeleteURL(self):
 
24
        c = Comment(id=12345)
 
25
        self.assertEqual(comments.get_delete_url(c), "/delete/12345/")
 
26
 
 
27
    def getGetApproveURL(self):
 
28
        c = Comment(id=12345)
 
29
        self.assertEqual(comments.get_approve_url(c), "/approve/12345/")
 
30
 
 
31
 
 
32
class CustomCommentTest(CommentTestCase):
 
33
    urls = 'regressiontests.comment_tests.urls'
 
34
 
 
35
    def setUp(self):
 
36
        self.old_comments_app = getattr(settings, 'COMMENTS_APP', None)
 
37
        settings.COMMENTS_APP = 'regressiontests.comment_tests.custom_comments'
 
38
        settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + [settings.COMMENTS_APP,]
 
39
 
 
40
    def tearDown(self):
 
41
        del settings.INSTALLED_APPS[-1]
 
42
        settings.COMMENTS_APP = self.old_comments_app
 
43
        if settings.COMMENTS_APP is None:
 
44
            delattr(settings._wrapped, 'COMMENTS_APP')
 
45
 
 
46
    def testGetCommentApp(self):
 
47
        from regressiontests.comment_tests import custom_comments
 
48
        self.assertEqual(comments.get_comment_app(), custom_comments)
 
49
 
 
50
    def testGetModel(self):
 
51
        from regressiontests.comment_tests.custom_comments.models import CustomComment
 
52
        self.assertEqual(comments.get_model(), CustomComment)
 
53
 
 
54
    def testGetForm(self):
 
55
        from regressiontests.comment_tests.custom_comments.forms import CustomCommentForm
 
56
        self.assertEqual(comments.get_form(), CustomCommentForm)
 
57
 
 
58
    def testGetFormTarget(self):
 
59
        self.assertEqual(comments.get_form_target(), "/post/")
 
60
 
 
61
    def testGetFlagURL(self):
 
62
        c = Comment(id=12345)
 
63
        self.assertEqual(comments.get_flag_url(c), "/flag/12345/")
 
64
 
 
65
    def getGetDeleteURL(self):
 
66
        c = Comment(id=12345)
 
67
        self.assertEqual(comments.get_delete_url(c), "/delete/12345/")
 
68
 
 
69
    def getGetApproveURL(self):
 
70
        c = Comment(id=12345)
 
71
        self.assertEqual(comments.get_approve_url(c), "/approve/12345/")