Commit 75f06852f16a26604c1046c5631bf1257c3ee5cb

Authored by Claude Paroz
1 parent a3885946

Added a test for too long comments

... ... @@ -6,7 +6,7 @@ from django.conf import settings
6 6 from django.contrib.auth.models import User
7 7
8 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 11 from . import CommentTestCase
12 12 from testapp.models import Article, Book
... ... @@ -69,6 +69,15 @@ class CommentViewTests(CommentTestCase):
69 69 response = self.client.post("/post/", data)
70 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 81 def testCommentPreview(self):
73 82 a = Article.objects.get(pk=1)
74 83 data = self.getValidData(a)
... ...
Please register or login to post a comment