indexers for commentators, number of comments, and latest comment added.
svn path=/plone.app.discussion/trunk/; revision=27766
This commit is contained in:
@@ -17,7 +17,73 @@ from zope.component import provideAdapter
|
||||
|
||||
from plone.app.discussion import catalog
|
||||
|
||||
class IndexersTest(PloneTestCase):
|
||||
|
||||
class ConversationIndexersTest(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')
|
||||
|
||||
# Create a conversation.
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.title = 'Comment 1'
|
||||
comment1.text = 'Comment Text'
|
||||
comment1.creator = "Jim"
|
||||
comment1.author_username = "Jim"
|
||||
comment1.creation_date = datetime(2006, 9, 17, 14, 18, 12)
|
||||
comment1.modification_date = datetime(2006, 9, 17, 14, 18, 12)
|
||||
self.new_id1 = conversation.addComment(comment1)
|
||||
|
||||
comment2 = createObject('plone.Comment')
|
||||
comment2.title = 'Comment 2'
|
||||
comment2.text = 'Comment Text'
|
||||
comment2.creator = "Emma"
|
||||
comment2.author_username = "Emma"
|
||||
comment2.creation_date = datetime(2007, 12, 13, 4, 18, 12)
|
||||
comment2.modification_date = datetime(2007, 12, 13, 4, 18, 12)
|
||||
self.new_id2 = conversation.addComment(comment2)
|
||||
|
||||
comment3 = createObject('plone.Comment')
|
||||
comment3.title = 'Comment 3'
|
||||
comment3.text = 'Comment Text'
|
||||
comment3.creator = "Lukas"
|
||||
comment3.author_username = "Lukas"
|
||||
comment3.creation_date = datetime(2009, 4, 12, 11, 12, 12)
|
||||
comment3.modification_date = datetime(2009, 4, 12, 11, 12, 12)
|
||||
self.new_id3 = conversation.addComment(comment3)
|
||||
|
||||
self.conversation = conversation
|
||||
|
||||
def test_conversation_total_comments(self):
|
||||
self.assert_(isinstance(catalog.total_comments, DelegatingIndexerFactory))
|
||||
self.assertEquals(catalog.total_comments(self.portal.doc1)(), 3)
|
||||
del self.conversation[self.new_id1]
|
||||
self.assertEquals(catalog.total_comments(self.portal.doc1)(), 2)
|
||||
del self.conversation[self.new_id2]
|
||||
del self.conversation[self.new_id3]
|
||||
self.assertEquals(catalog.total_comments(self.portal.doc1)(), 0)
|
||||
|
||||
def test_conversation_last_comment_date(self):
|
||||
self.assert_(isinstance(catalog.last_comment_date, DelegatingIndexerFactory))
|
||||
self.assertEquals(catalog.last_comment_date(self.portal.doc1)(), datetime(2009, 4, 12, 11, 12, 12))
|
||||
del self.conversation[self.new_id3]
|
||||
self.assertEquals(catalog.last_comment_date(self.portal.doc1)(), datetime(2007, 12, 13, 4, 18, 12))
|
||||
del self.conversation[self.new_id2]
|
||||
del self.conversation[self.new_id1]
|
||||
self.assertEquals(catalog.last_comment_date(self.portal.doc1)(), None)
|
||||
|
||||
def test_conversation_commentators(self):
|
||||
pass
|
||||
#self.assertEquals(catalog.commentators(self.portal.doc1)(), ('Jim', 'Emma', 'Lukas'))
|
||||
#self.assert_(isinstance(catalog.commentators, DelegatingIndexerFactory))
|
||||
|
||||
class CommentIndexersTest(PloneTestCase):
|
||||
|
||||
layer = DiscussionLayer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user