comment catalog tests added.

svn path=/plone.app.discussion/trunk/; revision=27631
This commit is contained in:
Timo Stollenwerk 2009-06-22 17:06:37 +00:00
parent 6d414055bc
commit a3e9105e48

View File

@ -4,7 +4,10 @@ from zope.component import createObject
from zope.component import getMultiAdapter from zope.component import getMultiAdapter
from Products.CMFCore.utils import getToolByName
from Products.PloneTestCase.ptc import PloneTestCase from Products.PloneTestCase.ptc import PloneTestCase
from plone.app.discussion.tests.layer import DiscussionLayer from plone.app.discussion.tests.layer import DiscussionLayer
from plone.app.discussion.interfaces import IComment, IConversation, IReplies from plone.app.discussion.interfaces import IComment, IConversation, IReplies
@ -113,6 +116,48 @@ class CommentTest(PloneTestCase):
# TODO: is this correct? Redirect ist 301 # TODO: is this correct? Redirect ist 301
self.assertEquals(200, self.app.REQUEST.response.getStatus()) 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): class RepliesTest(PloneTestCase):
# test the IReplies adapter on a comment # test the IReplies adapter on a comment