Ticket #10523: 10523.logentry-200-chars-repr.diff

File 10523.logentry-200-chars-repr.diff, 2.4 KB (added by julien, 3 years ago)

Passing test case

  • tests/regressiontests/admin_views/models.py

    diff --git a/tests/regressiontests/admin_views/models.py b/tests/regressiontests/admin_views/models.py
    index bb8d026..4f18743 100644
    a b class Article(models.Model): 
    2323    """
    2424    A simple article to test admin views. Test backwards compatibility.
    2525    """
    26     title = models.CharField(max_length=100)
     26    title = models.CharField(max_length=255)
    2727    content = models.TextField()
    2828    date = models.DateTimeField()
    2929    section = models.ForeignKey(Section, null=True, blank=True)
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index b6e7b9e..07b569c 100644
    a b class AdminViewPermissionsTest(TestCase): 
    10641064        self.assertContains(response, 'id="login-form"')
    10651065
    10661066
     1067    def testLongUnicodeLogEntry(self):
     1068        # Add an article
     1069        add_dict = {'title' : ''.join([u'ä' for x in range(255)]),
     1070                    'content': '<p>great article</p>',
     1071                    'date_0': '2008-03-18', 'date_1': '10:54:39',
     1072                    'section': 1}
     1073        self.client.post('/test_admin/admin/', self.adduser_login)
     1074        post = self.client.post('/test_admin/admin/admin_views/article/add/', add_dict)
     1075        self.assertRedirects(post, '/test_admin/admin/')
     1076        article = Article.objects.order_by('-id')[0]
     1077        self.assertEqual(LogEntry.objects.all().count(), 1)
     1078        logentry = LogEntry.objects.order_by('-id')[0]
     1079        self.assertEqual(logentry.object_repr, ''.join([u'ä' for x in range(200)]))
     1080        self.client.get('/test_admin/admin/logout/')
     1081
     1082        # Delete the article
     1083        delete_dict = {'post': 'yes'}
     1084        self.client.post('/test_admin/admin/', self.deleteuser_login)
     1085        post = self.client.post('/test_admin/admin/admin_views/article/%s/delete/' % article.id, delete_dict)
     1086        self.assertRedirects(post, '/test_admin/admin/')
     1087        self.assertEqual(LogEntry.objects.all().count(), 2)
     1088        logentry = LogEntry.objects.order_by('-id')[0]
     1089        self.assertEqual(logentry.object_repr, ''.join([u'ä' for x in range(200)]))
     1090        self.client.get('/test_admin/admin/logout/')
     1091
    10671092class AdminViewDeletedObjectsTest(TestCase):
    10681093    urls = "regressiontests.admin_views.urls"
    10691094    fixtures = ['admin-views-users.xml', 'deleted-objects.xml']
Back to Top