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
7
class CommentAppAPITests(CommentTestCase):
8
"""Tests for the "comment app" API"""
10
def testGetCommentApp(self):
11
self.assertEqual(comments.get_comment_app(), comments)
13
def testGetForm(self):
14
self.assertEqual(comments.get_form(), CommentForm)
16
def testGetFormTarget(self):
17
self.assertEqual(comments.get_form_target(), "/post/")
19
def testGetFlagURL(self):
21
self.assertEqual(comments.get_flag_url(c), "/flag/12345/")
23
def getGetDeleteURL(self):
25
self.assertEqual(comments.get_delete_url(c), "/delete/12345/")
27
def getGetApproveURL(self):
29
self.assertEqual(comments.get_approve_url(c), "/approve/12345/")
32
class CustomCommentTest(CommentTestCase):
33
urls = 'regressiontests.comment_tests.urls'
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,]
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')
46
def testGetCommentApp(self):
47
from regressiontests.comment_tests import custom_comments
48
self.assertEqual(comments.get_comment_app(), custom_comments)
50
def testGetModel(self):
51
from regressiontests.comment_tests.custom_comments.models import CustomComment
52
self.assertEqual(comments.get_model(), CustomComment)
54
def testGetForm(self):
55
from regressiontests.comment_tests.custom_comments.forms import CustomCommentForm
56
self.assertEqual(comments.get_form(), CustomCommentForm)
58
def testGetFormTarget(self):
59
self.assertEqual(comments.get_form_target(), "/post/")
61
def testGetFlagURL(self):
63
self.assertEqual(comments.get_flag_url(c), "/flag/12345/")
65
def getGetDeleteURL(self):
67
self.assertEqual(comments.get_delete_url(c), "/delete/12345/")
69
def getGetApproveURL(self):
71
self.assertEqual(comments.get_approve_url(c), "/approve/12345/")