Commit 75f06852f16a26604c1046c5631bf1257c3ee5cb
1 parent
a3885946
Added a test for too long comments
Showing
1 changed file
with
10 additions
and
1 deletions
| @@ -6,7 +6,7 @@ from django.conf import settings | @@ -6,7 +6,7 @@ from django.conf import settings | ||
| 6 | from django.contrib.auth.models import User | 6 | from django.contrib.auth.models import User |
| 7 | 7 | ||
| 8 | from django_comments import signals | 8 | from django_comments import signals |
| 9 | -from django_comments.models import Comment | 9 | +from django_comments.models import COMMENT_MAX_LENGTH, Comment |
| 10 | 10 | ||
| 11 | from . import CommentTestCase | 11 | from . import CommentTestCase |
| 12 | from testapp.models import Article, Book | 12 | from testapp.models import Article, Book |
| @@ -69,6 +69,15 @@ class CommentViewTests(CommentTestCase): | @@ -69,6 +69,15 @@ class CommentViewTests(CommentTestCase): | ||
| 69 | response = self.client.post("/post/", data) | 69 | response = self.client.post("/post/", data) |
| 70 | self.assertEqual(response.status_code, 400) | 70 | self.assertEqual(response.status_code, 400) |
| 71 | 71 | ||
| 72 | + def testPostTooLongComment(self): | ||
| 73 | + a = Article.objects.get(pk=1) | ||
| 74 | + data = self.getValidData(a) | ||
| 75 | + data["comment"] = "X" * (COMMENT_MAX_LENGTH + 1) | ||
| 76 | + response = self.client.post("/post/", data) | ||
| 77 | + self.assertContains( | ||
| 78 | + response, "Ensure this value has at most %d characters" % COMMENT_MAX_LENGTH | ||
| 79 | + ) | ||
| 80 | + | ||
| 72 | def testCommentPreview(self): | 81 | def testCommentPreview(self): |
| 73 | a = Article.objects.get(pk=1) | 82 | a = Article.objects.get(pk=1) |
| 74 | data = self.getValidData(a) | 83 | data = self.getValidData(a) |
Please
register
or
login
to post a comment