Ticket #9956: comments_urls_9956.diff

File comments_urls_9956.diff, 8.4 KB (added by Kevin Kubasik, 15 years ago)
  • django/contrib/comments/urls.py

    diff --git a/django/contrib/comments/urls.py b/django/contrib/comments/urls.py
    index ae0b7ff..151f253 100644
    a b urlpatterns = patterns('django.contrib.comments.views',  
    1313)
    1414
    1515urlpatterns += patterns('',
    16     url(r'^cr/(\d+)/(\w+)/$', 'django.views.defaults.shortcut', name='comments-url-redirect'),
     16    url(r'^cr/(\d+)/((\w|-)+)/$', 'django.views.defaults.shortcut', name='comments-url-redirect'),
    1717)
    1818
  • tests/regressiontests/comment_tests/fixtures/comment_utils.xml

    diff --git a/tests/regressiontests/comment_tests/fixtures/comment_utils.xml b/tests/regressiontests/comment_tests/fixtures/comment_utils.xml
    index a39bbf6..d874ab5 100644
    a b  
    1212      <field type="DateField" name="pub_date">2008-01-02</field>
    1313      <field type="BooleanField" name="enable_comments">False</field>
    1414  </object>
     15  <object pk="1" model="comment_tests.slugpost">
     16      <field type="SlugField" name="slug">test-this</field>
     17  </object>
    1518</django-objects>
  • tests/regressiontests/comment_tests/models.py

    diff --git a/tests/regressiontests/comment_tests/models.py b/tests/regressiontests/comment_tests/models.py
    index 62f4168..e66fc75 100644
    a b class Entry(models.Model):  
    2828
    2929    def __str__(self):
    3030        return self.title
     31
     32class SlugPost(models.Model):
     33    """A Post like model whos PK is a slug"""
     34    slug = models.SlugField(primary_key=True,max_length=100)
     35   
     36    def __str__(self):
     37        return self.slug
     38   
     39   
     40 No newline at end of file
  • tests/regressiontests/comment_tests/tests/__init__.py

    diff --git a/tests/regressiontests/comment_tests/tests/__init__.py b/tests/regressiontests/comment_tests/tests/__init__.py
    index 449fea4..7ceabfc 100644
    a b from django.contrib.comments.models import Comment  
    44from django.contrib.contenttypes.models import ContentType
    55from django.contrib.sites.models import Site
    66from django.test import TestCase
    7 from regressiontests.comment_tests.models import Article, Author
     7from regressiontests.comment_tests.models import Article, Author, SlugPost
    88
    99# Shortcut
    1010CT = ContentType.objects.get_for_model
    class CommentTestCase(TestCase):  
    5555            comment = "Damn, I wanted to be first.",
    5656            site = Site.objects.get_current(),
    5757        )
     58       
    5859        c4 = Comment.objects.create(
    5960            content_type = CT(Author),
    6061            object_pk = "2",
    class CommentTestCase(TestCase):  
    6364            comment = "You get here first, too?",
    6465            site = Site.objects.get_current(),
    6566        )
     67       
     68        c5 = Comment.objects.create(
     69            content_type = CT(SlugPost),
     70            object_pk = "test-this",
     71            user = user,
     72            user_url = "http://example.com/~frank/",
     73            comment = "Wonder how the slugs work",
     74            site = Site.objects.get_current(),
     75        )
    6676
    67         return c1, c2, c3, c4
     77        return c1, c2, c3, c4, c5
    6878
    6979    def getData(self):
    7080        return {
  • tests/regressiontests/comment_tests/tests/comment_view_tests.py

    diff --git a/tests/regressiontests/comment_tests/tests/comment_view_tests.py b/tests/regressiontests/comment_tests/tests/comment_view_tests.py
    index 312fab6..0ee2e61 100644
    a b from django.conf import settings  
    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 django.core import urlresolvers
     7from regressiontests.comment_tests.models import Article, SlugPost
    78from regressiontests.comment_tests.tests import CommentTestCase
    89
    910post_redirect_re = re.compile(r'^http://testserver/posted/\?c=(?P<pk>\d+$)')
    class CommentViewTests(CommentTestCase):  
    206207        response = self.client.get(location)
    207208        self.assertTemplateUsed(response, "comments/posted.html")
    208209        self.assertEqual(response.context[0]["comment"], Comment.objects.get(pk=pk))
    209 
     210       
     211    #----------------------------------------------------------------------
     212    def testCommentUrlLookup(self):
     213        """"""
     214        c1, c2, c3, c4, c5 = self.createSomeComments()
     215        c5.save()
     216        sp = Comment.objects.get(object_pk='test-this')
     217        url = urlresolvers.reverse("comments-url-redirect",
     218                                   args=(c5.content_type_id, c5.object_pk))
     219        self.assertEqual(url,'/cr/%i/%s/' % (c5.content_type_id,c5.object_pk) )
  • tests/regressiontests/comment_tests/tests/model_tests.py

    diff --git a/tests/regressiontests/comment_tests/tests/model_tests.py b/tests/regressiontests/comment_tests/tests/model_tests.py
    index 17797bb..99e6d08 100644
    a b class CommentModelTests(CommentTestCase):  
    99            self.failIfEqual(c.submit_date, None)
    1010
    1111    def testUserProperties(self):
    12         c1, c2, c3, c4 = self.createSomeComments()
     12        c1, c2, c3, c4, c5 = self.createSomeComments()
    1313        self.assertEqual(c1.name, "Joe Somebody")
    1414        self.assertEqual(c2.email, "jsomebody@example.com")
    1515        self.assertEqual(c3.name, "Frank Nobody")
    class CommentManagerTests(CommentTestCase):  
    2121
    2222    def testInModeration(self):
    2323        """Comments that aren't public are considered in moderation"""
    24         c1, c2, c3, c4 = self.createSomeComments()
     24        c1, c2, c3, c4, c5 = self.createSomeComments()
    2525        c1.is_public = False
    2626        c2.is_public = False
    2727        c1.save()
    class CommentManagerTests(CommentTestCase):  
    3131
    3232    def testRemovedCommentsNotInModeration(self):
    3333        """Removed comments are not considered in moderation"""
    34         c1, c2, c3, c4 = self.createSomeComments()
     34        c1, c2, c3, c4, c5 = self.createSomeComments()
    3535        c1.is_public = False
    3636        c2.is_public = False
    3737        c2.is_removed = True
    class CommentManagerTests(CommentTestCase):  
    4141        self.assertEqual(moderated_comments, [c1])
    4242
    4343    def testForModel(self):
    44         c1, c2, c3, c4 = self.createSomeComments()
     44        c1, c2, c3, c4, c5 = self.createSomeComments()
    4545        article_comments = list(Comment.objects.for_model(Article).order_by("id"))
    4646        author_comments = list(Comment.objects.for_model(Author.objects.get(pk=1)))
    4747        self.assertEqual(article_comments, [c1, c3])
  • tests/regressiontests/comment_tests/tests/moderation_view_tests.py

    diff --git a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py
    index b9eadd7..739c7d6 100644
    a b class ApproveViewTests(CommentTestCase):  
    130130
    131131    def testApprovePost(self):
    132132        """POSTing the delete view should mark the comment as removed"""
    133         c1, c2, c3, c4 = self.createSomeComments()
     133        c1, c2, c3, c4, c5 = self.createSomeComments()
    134134        c1.is_public = False; c1.save()
    135135
    136136        makeModerator("normaluser")
    class ModerationQueueTests(CommentTestCase):  
    174174
    175175    def testModerationQueueContents(self):
    176176        """Moderation queue should display non-public, non-removed comments."""
    177         c1, c2, c3, c4 = self.createSomeComments()
     177        c1, c2, c3, c4, c5 = self.createSomeComments()
    178178        makeModerator("normaluser")
    179179        self.client.login(username="normaluser", password="normaluser")
    180180
  • tests/regressiontests/comment_tests/tests/templatetag_tests.py

    diff --git a/tests/regressiontests/comment_tests/tests/templatetag_tests.py b/tests/regressiontests/comment_tests/tests/templatetag_tests.py
    index a1187ca..ae400f2 100644
    a b class CommentTemplateTagTests(CommentTestCase):  
    5252        self.testGetCommentCount("{% get_comment_count for a as cc %}")
    5353
    5454    def testGetCommentList(self, tag=None):
    55         c1, c2, c3, c4 = self.createSomeComments()
     55        c1, c2, c3, c4, c5 = self.createSomeComments()
    5656        t = "{% load comments %}" + (tag or "{% get_comment_list for comment_tests.author a.id as cl %}")
    5757        ctx, out = self.render(t, a=Author.objects.get(pk=1))
    5858        self.assertEqual(out, "")
Back to Top