2009-05-16 17:05:22 +02:00
|
|
|
import unittest
|
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
from zope.component import getUtility, createObject
|
2009-05-16 17:05:22 +02:00
|
|
|
|
2009-05-18 16:16:48 +02:00
|
|
|
from Products.PloneTestCase.ptc import PloneTestCase
|
|
|
|
from plone.app.discussion.tests.layer import DiscussionLayer
|
2009-05-16 17:05:22 +02:00
|
|
|
|
|
|
|
from plone.app.discussion.interfaces import ICommentingTool, IConversation
|
|
|
|
|
2009-05-18 16:16:48 +02:00
|
|
|
class ToolTest(PloneTestCase):
|
2009-06-18 22:57:47 +02:00
|
|
|
|
2009-05-18 16:16:48 +02:00
|
|
|
layer = DiscussionLayer
|
2009-06-18 22:57:47 +02:00
|
|
|
|
2009-05-16 17:05:22 +02:00
|
|
|
def afterSetUp(self):
|
|
|
|
# XXX If we make this a layer, it only get run once...
|
|
|
|
# First we need to create some content.
|
|
|
|
self.loginAsPortalOwner()
|
|
|
|
typetool = self.portal.portal_types
|
|
|
|
typetool.constructContent('Document', self.portal, 'doc1')
|
2009-06-18 22:57:47 +02:00
|
|
|
|
2009-05-16 17:05:22 +02:00
|
|
|
def test_tool_indexing(self):
|
|
|
|
# Create a conversation. In this case we doesn't assign it to an
|
|
|
|
# object, as we just want to check the Conversation object API.
|
|
|
|
conversation = IConversation(self.portal.doc1)
|
2009-06-18 22:57:47 +02:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
# Add a comment.
|
|
|
|
comment = createObject('plone.Comment')
|
2009-05-16 17:05:22 +02:00
|
|
|
comment.title = 'Comment 1'
|
|
|
|
comment.text = 'Comment text'
|
2009-06-18 22:57:47 +02:00
|
|
|
|
2009-05-16 17:05:22 +02:00
|
|
|
conversation.addComment(comment)
|
2009-06-18 22:57:47 +02:00
|
|
|
|
2009-05-16 17:05:22 +02:00
|
|
|
# Check that the comment got indexed in the tool:
|
|
|
|
tool = getUtility(ICommentingTool)
|
2009-05-17 20:38:45 +02:00
|
|
|
comment = list(tool.searchResults())
|
|
|
|
self.assert_(len(comment) == 1, "There is only one comment, but we got"
|
|
|
|
" %s results in the search" % len(comment))
|
|
|
|
self.assertEquals(comment[0].Title, 'Comment 1')
|
2009-06-18 22:57:47 +02:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
def test_unindexing(self):
|
|
|
|
pass
|
2009-06-18 22:57:47 +02:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
def test_search(self):
|
|
|
|
# search returns only comments
|
|
|
|
pass
|
2009-06-18 22:57:47 +02:00
|
|
|
|
2009-05-16 17:05:22 +02:00
|
|
|
def test_suite():
|
2009-05-18 16:16:48 +02:00
|
|
|
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|