Make sure comment UIDs in the catalog are always unique. This fixes

http://dev.plone.org/plone/ticket/10652. We depend on plone.uuid and plone.app.uuid now. Refs #10652.

svn path=/plone.app.discussion/trunk/; revision=46005
This commit is contained in:
Timo Stollenwerk
2010-11-28 11:39:19 +00:00
parent 664e5c273e
commit ac4a64f55d
5 changed files with 47 additions and 2 deletions
+35 -1
View File
@@ -9,6 +9,8 @@ from zope.component import createObject
from zope.component import getMultiAdapter
from Products.CMFCore.utils import getToolByName
from Products.PloneTestCase.ptc import PloneTestCase
from plone.app.discussion.tests.layer import DiscussionLayer
@@ -32,7 +34,10 @@ class CommentTest(PloneTestCase):
self.portal.invokeFactory(id='doc1',
title='Document 1',
type_name='Document')
self.catalog = getToolByName(self.portal, 'portal_catalog')
self.document_brain = self.catalog.searchResults(
portal_type = 'Document')[0]
def test_factory(self):
comment1 = createObject('plone.Comment')
self.assert_(IComment.providedBy(comment1))
@@ -60,6 +65,35 @@ class CommentTest(PloneTestCase):
self.assertEquals('123', comment1.getId())
self.assertEquals(u'123', comment1.__name__)
def test_uid(self):
conversation = IConversation(self.portal.doc1)
comment1 = createObject('plone.Comment')
conversation.addComment(comment1)
comment_brain = self.catalog.searchResults(
portal_type = 'Discussion Item')[0]
self.failUnless(comment_brain.UID)
def test_uid_is_unique(self):
conversation = IConversation(self.portal.doc1)
comment1 = createObject('plone.Comment')
conversation.addComment(comment1)
comment2 = createObject('plone.Comment')
conversation.addComment(comment2)
brains = self.catalog.searchResults(
portal_type = 'Discussion Item')
self.assertNotEquals(brains[0].UID, None)
self.assertNotEquals(brains[1].UID, None)
self.assertNotEquals(brains[0].UID, brains[1].UID)
def test_comment_uid_differs_from_content_uid(self):
conversation = IConversation(self.portal.doc1)
comment1 = createObject('plone.Comment')
conversation.addComment(comment1)
comment_brain = self.catalog.searchResults(
portal_type = 'Discussion Item')[0]
self.assertNotEquals(comment_brain.UID, None)
self.assertNotEquals(self.document_brain.UID, comment_brain.UID)
def test_title(self):
conversation = IConversation(self.portal.doc1)
comment1 = createObject('plone.Comment')