From a3e9105e48c4c1d28cd5ed3f85a80ddfbba5c21b Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Mon, 22 Jun 2009 17:06:37 +0000 Subject: [PATCH] comment catalog tests added. svn path=/plone.app.discussion/trunk/; revision=27631 --- plone/app/discussion/tests/test_comment.py | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/plone/app/discussion/tests/test_comment.py b/plone/app/discussion/tests/test_comment.py index 95bb945..98a2540 100644 --- a/plone/app/discussion/tests/test_comment.py +++ b/plone/app/discussion/tests/test_comment.py @@ -4,7 +4,10 @@ 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 from plone.app.discussion.interfaces import IComment, IConversation, IReplies @@ -113,6 +116,48 @@ class CommentTest(PloneTestCase): # TODO: is this correct? Redirect ist 301 self.assertEquals(200, self.app.REQUEST.response.getStatus()) +class CatalogTest(PloneTestCase): + + layer = DiscussionLayer + + def afterSetUp(self): + # First we need to create some content. + self.loginAsPortalOwner() + typetool = self.portal.portal_types + typetool.constructContent('Document', self.portal, 'doc1') + + self.catalog = getToolByName(self.portal, 'portal_catalog') + + conversation = IConversation(self.portal.doc1) + + comment1 = createObject('plone.Comment') + comment1.title = 'Comment 1' + comment1.text = 'Comment text' + comment1.creator = 'Jim' + + new_comment1_id = conversation.addComment(comment1) + self.comment_id = new_comment1_id + + self.comment = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_comment1_id) + + brains = self.catalog.searchResults( + path = {'query' : '/'.join(self.comment.getPhysicalPath()) }) + self.comment_brain = brains[0] + + def test_title(self): + self.assertEquals(self.comment_brain.Title, 'Comment 1') + + def test_type(self): + self.assertEquals(self.comment_brain.portal_type, 'Discussion Item') + self.assertEquals(self.comment_brain.meta_type, 'Discussion Item') + self.assertEquals(self.comment_brain.Type, 'Discussion Item') + + def test_review_state(self): + self.assertEquals(self.comment_brain.review_state, 'published') + + def test_creator(self): + self.assertEquals(self.comment_brain.Creator, 'Jim') + class RepliesTest(PloneTestCase): # test the IReplies adapter on a comment