1
0
mirror of https://github.com/django/django.git synced 2024-12-25 02:26:12 +00:00

Fixed #12724: Fixed new comment tests to not hardcode comment primary key values. Thanks carljm.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12345 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Karen Tracey 2010-01-28 19:23:54 +00:00
parent e808fc898b
commit 59cccd1474

View File

@ -66,22 +66,22 @@ class CommentTemplateTagTests(CommentTestCase):
self.testGetCommentList("{% get_comment_list for a as cl %}") self.testGetCommentList("{% get_comment_list for a as cl %}")
def testGetCommentPermalink(self): def testGetCommentPermalink(self):
self.createSomeComments() c1, c2, c3, c4 = self.createSomeComments()
t = "{% load comments %}{% get_comment_list for comment_tests.author author.id as cl %}" t = "{% load comments %}{% get_comment_list for comment_tests.author author.id as cl %}"
t += "{% get_comment_permalink cl.0 %}" t += "{% get_comment_permalink cl.0 %}"
ct = ContentType.objects.get_for_model(Author) ct = ContentType.objects.get_for_model(Author)
author = Author.objects.get(pk=1) author = Author.objects.get(pk=1)
ctx, out = self.render(t, author=author) ctx, out = self.render(t, author=author)
self.assertEqual(out, "/cr/%s/%s/#c2" % (ct.id, author.id)) self.assertEqual(out, "/cr/%s/%s/#c%s" % (ct.id, author.id, c2.id))
def testGetCommentPermalinkFormatted(self): def testGetCommentPermalinkFormatted(self):
self.createSomeComments() c1, c2, c3, c4 = self.createSomeComments()
t = "{% load comments %}{% get_comment_list for comment_tests.author author.id as cl %}" t = "{% load comments %}{% get_comment_list for comment_tests.author author.id as cl %}"
t += "{% get_comment_permalink cl.0 '#c%(id)s-by-%(user_name)s' %}" t += "{% get_comment_permalink cl.0 '#c%(id)s-by-%(user_name)s' %}"
ct = ContentType.objects.get_for_model(Author) ct = ContentType.objects.get_for_model(Author)
author = Author.objects.get(pk=1) author = Author.objects.get(pk=1)
ctx, out = self.render(t, author=author) ctx, out = self.render(t, author=author)
self.assertEqual(out, "/cr/%s/%s/#c2-by-Joe Somebody" % (ct.id, author.id)) self.assertEqual(out, "/cr/%s/%s/#c%s-by-Joe Somebody" % (ct.id, author.id, c2.id))
def testRenderCommentList(self, tag=None): def testRenderCommentList(self, tag=None):
t = "{% load comments %}" + (tag or "{% render_comment_list for comment_tests.article a.id %}") t = "{% load comments %}" + (tag or "{% render_comment_list for comment_tests.article a.id %}")