2011-04-16 11:30:11 +02:00
|
|
|
import unittest2 as unittest
|
2009-05-16 17:05:22 +02:00
|
|
|
|
2010-07-12 15:49:57 +02:00
|
|
|
from zope.component import queryUtility, createObject
|
2009-05-16 17:05:22 +02:00
|
|
|
|
2011-04-16 11:30:11 +02:00
|
|
|
from plone.app.testing import TEST_USER_ID, setRoles
|
|
|
|
|
2012-01-14 07:41:50 +01:00
|
|
|
from plone.app.discussion.testing import \
|
|
|
|
PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
2009-05-16 17:05:22 +02:00
|
|
|
|
|
|
|
from plone.app.discussion.interfaces import ICommentingTool, IConversation
|
|
|
|
|
2012-01-14 07:41:50 +01:00
|
|
|
|
2011-04-16 11:30:11 +02:00
|
|
|
class ToolTest(unittest.TestCase):
|
2009-06-18 22:57:47 +02:00
|
|
|
|
2011-04-16 11:30:11 +02:00
|
|
|
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
2009-06-18 22:57:47 +02:00
|
|
|
|
2011-04-16 11:30:11 +02:00
|
|
|
def setUp(self):
|
|
|
|
self.portal = self.layer['portal']
|
|
|
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
2010-12-16 00:52:56 +01:00
|
|
|
self.portal.invokeFactory(id='doc1',
|
|
|
|
title='Document 1',
|
2010-09-29 09:56:36 +02:00
|
|
|
type_name='Document')
|
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')
|
2012-01-30 13:30:46 +01:00
|
|
|
comment.creator = 'jim'
|
|
|
|
comment.author_name = "Jim"
|
2009-05-16 17:05:22 +02:00
|
|
|
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:
|
2010-07-12 15:49:57 +02:00
|
|
|
tool = queryUtility(ICommentingTool)
|
2009-05-17 20:38:45 +02:00
|
|
|
comment = list(tool.searchResults())
|
2012-01-14 07:41:50 +01:00
|
|
|
self.assertTrue(len(comment) == 1,
|
|
|
|
"There is only one comment, but we got"
|
|
|
|
" %s results in the search" % len(comment))
|
2011-04-15 18:23:38 +02:00
|
|
|
self.assertEqual(comment[0].Title, 'Jim on Document 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
|
|
|
|
2012-01-14 07:41:50 +01:00
|
|
|
|
2009-05-16 17:05:22 +02:00
|
|
|
def test_suite():
|
2010-08-28 19:06:53 +02:00
|
|
|
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|