Ticket #11716: failure_case.patch

File failure_case.patch, 2.4 KB (added by Leo Shklovskii, 12 years ago)

Example failure case from not catching ValidationError

  • tests/regressiontests/comment_tests/fixtures/comment_tests.json

     
    11[
    22  {
     3    "model" : "comment_tests.book",
     4    "pk" : 1,
     5    "fields" : {
     6        "dewey_decimal" : "12.34"
     7    }
     8  },
     9  {
    310    "model" : "comment_tests.author",
    411    "pk" : 1,
    512    "fields" : {
  • tests/regressiontests/comment_tests/models.py

     
    2828
    2929    def __str__(self):
    3030        return self.title
     31
     32class Book(models.Model):
     33    dewey_decimal = models.DecimalField(primary_key = True, decimal_places=2, max_digits=5)
     34   
     35 No newline at end of file
  • tests/regressiontests/comment_tests/tests/comment_view_tests.py

     
    33from django.contrib.auth.models import User
    44from django.contrib.comments import signals
    55from django.contrib.comments.models import Comment
    6 from regressiontests.comment_tests.models import Article
     6from regressiontests.comment_tests.models import Article, Book
    77from regressiontests.comment_tests.tests import CommentTestCase
    88
    99post_redirect_re = re.compile(r'^http://testserver/posted/\?c=(?P<pk>\d+$)')
    1010
    1111class CommentViewTests(CommentTestCase):
     12    def testBook(self):
     13        b = Book.objects.get(pk='12.34')
     14        data = self.getValidData(b)
     15        data["comment"] = "This is another comment"
     16        data["object_pk"] = 'cookies'
     17        response = self.client.post("/post/", data)
     18        self.assertEqual(response.status_code, 405)
     19        self.assertEqual(response["Allow"], "POST")
    1220
    1321    def testPostCommentHTTPMethods(self):
    1422        a = Article.objects.get(pk=1)
     
    234242        broken_location = location + u"\ufffd"
    235243        response = self.client.get(broken_location)
    236244        self.assertEqual(response.status_code, 200)
     245
Back to Top