PageRenderTime 26ms CodeModel.GetById 16ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/comment_tests/tests/app_api_tests.py

https://code.google.com/p/mango-py/
Python | 71 lines | 70 code | 1 blank | 0 comment | 0 complexity | 1d74a93ebb9a3595c10d6e617bf1735f MD5 | raw file
 1from django.conf import settings
 2from django.contrib import comments
 3from django.contrib.comments.models import Comment
 4from django.contrib.comments.forms import CommentForm
 5from regressiontests.comment_tests.tests import CommentTestCase
 6
 7class 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
32class 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            del 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/")