Skip to content

Commit ffd1964

Browse files
committed
replace hardcoded Comment and CommentForm with get_model and get_form for use in custom comment app tests
1 parent 8532540 commit ffd1964

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tests/testapp/tests/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from django.test import TestCase
88
from django.test.utils import override_settings
99

10-
from django_comments.forms import CommentForm
11-
from django_comments.models import Comment
10+
from django_comments import get_model, get_form
1211

1312
from testapp.models import Article, Author
1413

@@ -42,7 +41,7 @@ def tearDown(self):
4241

4342
def createSomeComments(self):
4443
# Two anonymous comments on two different objects
45-
c1 = Comment.objects.create(
44+
c1 = get_model().objects.create(
4645
content_type=CT(Article),
4746
object_pk="1",
4847
user_name="Joe Somebody",
@@ -51,7 +50,7 @@ def createSomeComments(self):
5150
comment="First!",
5251
site=Site.objects.get_current(),
5352
)
54-
c2 = Comment.objects.create(
53+
c2 = get_model().objects.create(
5554
content_type=CT(Author),
5655
object_pk="1",
5756
user_name="Joe Somebody",
@@ -73,15 +72,15 @@ def createSomeComments(self):
7372
is_active=True,
7473
is_superuser=False,
7574
)
76-
c3 = Comment.objects.create(
75+
c3 = get_model().objects.create(
7776
content_type=CT(Article),
7877
object_pk="1",
7978
user=user,
8079
user_url="http://example.com/~frank/",
8180
comment="Damn, I wanted to be first.",
8281
site=Site.objects.get_current(),
8382
)
84-
c4 = Comment.objects.create(
83+
c4 = get_model().objects.create(
8584
content_type=CT(Author),
8685
object_pk="2",
8786
user=user,
@@ -101,7 +100,7 @@ def getData(self):
101100
}
102101

103102
def getValidData(self, obj):
104-
f = CommentForm(obj)
103+
f = get_form()(obj)
105104
d = self.getData()
106105
d.update(f.initial)
107106
return d

0 commit comments

Comments
 (0)