Skip to content

Commit 9cdb1b7

Browse files
committed
separate custom comment app tests into new class
1 parent 24404fc commit 9cdb1b7

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

tests/testapp/tests/test_comment_views.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
from django.conf import settings
2-
32
from django.contrib.auth.models import User
43
from django.core.files.uploadedfile import SimpleUploadedFile
54
from django.test.utils import override_settings
65

7-
import django_comments
8-
from django_comments import signals
6+
from django_comments import signals, get_model
97
from django_comments.abstracts import COMMENT_MAX_LENGTH
108
from django_comments.models import Comment
119

@@ -89,20 +87,6 @@ def testPostTooLongComment(self):
8987
response, "Ensure this value has at most %d characters" % COMMENT_MAX_LENGTH
9088
)
9189

92-
@override_settings(
93-
COMMENTS_APP='custom_comments',
94-
)
95-
def testPostCommentWithFile(self):
96-
a = Article.objects.get(pk=1)
97-
data = self.getValidData(a)
98-
test_file = SimpleUploadedFile("test_file.txt", b"file_content")
99-
data["file"] = test_file
100-
response = self.client.post("/post/", data)
101-
self.assertEqual(response.status_code, 302)
102-
custom_comment = django_comments.get_model().objects.first()
103-
self.assertTrue(custom_comment.file)
104-
self.assertEqual(custom_comment.file.read(), b"file_content")
105-
10690
def testCommentPreview(self):
10791
a = Article.objects.get(pk=1)
10892
data = self.getValidData(a)
@@ -377,3 +361,18 @@ def testCommentNextWithQueryStringAndAnchor(self):
377361
'/somewhere/else/?c=%s#baz' % Comment.objects.latest('id').pk,
378362
fetch_redirect_response=False,
379363
)
364+
365+
@override_settings(
366+
COMMENTS_APP='custom_comments',
367+
)
368+
class CustomCommentViewTests(CommentTestCase):
369+
def testPostCommentWithFile(self):
370+
a = Article.objects.get(pk=1)
371+
data = self.getValidData(a)
372+
test_file = SimpleUploadedFile("test_file.txt", b"file_content")
373+
data["file"] = test_file
374+
response = self.client.post("/post/", data)
375+
self.assertEqual(response.status_code, 302)
376+
custom_comment = get_model().objects.first()
377+
self.assertTrue(custom_comment.file)
378+
self.assertEqual(custom_comment.file.read(), b"file_content")

0 commit comments

Comments
 (0)