moderation view tests added.
svn path=/plone.app.discussion/trunk/; revision=27679
This commit is contained in:
parent
ffcdfc22e5
commit
4cc26a6421
@ -35,22 +35,53 @@ class ModerationViewTest(PloneTestCase):
|
||||
request = self.app.REQUEST
|
||||
context = getattr(self.portal, 'doc1')
|
||||
self.view = View(context, request)
|
||||
self.portal.portal_workflow.setChainForPortalTypes(('Discussion Item',), 'comment_review_workflow')
|
||||
self.wf_tool = self.portal.portal_workflow
|
||||
|
||||
# Add a conversation with three comments
|
||||
|
||||
def test_comments_pending_review(self):
|
||||
|
||||
# Add a conversation with a comment and two replies
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
comment = createObject('plone.Comment')
|
||||
comment.title = 'Comment 1'
|
||||
comment.text = 'Comment text'
|
||||
comment.Creator = 'Jim'
|
||||
comment.author_username = 'jim'
|
||||
new_id = conversation.addComment(comment)
|
||||
|
||||
self.view.comments_pending_review()
|
||||
# Todo
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.title = 'Comment 1'
|
||||
comment1.text = 'Comment text'
|
||||
comment1.Creator = 'Jim'
|
||||
new_id_1 = conversation.addComment(comment1)
|
||||
self.comment1 = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_id_1)
|
||||
|
||||
comment2 = createObject('plone.Comment')
|
||||
comment2.title = 'Comment 2'
|
||||
comment2.text = 'Comment text'
|
||||
comment2.Creator = 'Joe'
|
||||
new_id_2 = conversation.addComment(comment2)
|
||||
self.comment2 = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_id_2)
|
||||
|
||||
comment3 = createObject('plone.Comment')
|
||||
comment3.title = 'Comment 3'
|
||||
comment3.text = 'Comment text'
|
||||
comment3.Creator = 'Emma'
|
||||
new_id_3 = conversation.addComment(comment3)
|
||||
self.comment3 = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_id_3)
|
||||
|
||||
def test_comments_all(self):
|
||||
self.failUnless(self.view.comments_all())
|
||||
self.assertEquals(len(self.view.comments_all()), 3)
|
||||
|
||||
def test_comments_pending(self):
|
||||
self.wf_tool.getInfoFor(self.comment1, 'review_state')
|
||||
self.failUnless(self.view.comments_pending())
|
||||
self.assertEquals(len(self.view.comments_pending()), 3)
|
||||
self.portal.portal_workflow.doActionFor(self.comment1, action='publish')
|
||||
#self.comment1.reindexObject()
|
||||
#self.assertEquals(len(self.view.comments_pending()), 2)
|
||||
|
||||
def test_comments_published(self):
|
||||
self.assertEquals(len(self.view.comments_published()), 0)
|
||||
self.wf_tool.doActionFor(self.comment1, action='publish')
|
||||
#self.assertEquals(len(self.view.comments_published()), 1)
|
||||
|
||||
def test_comments_spam(self):
|
||||
self.view.comments_spam()
|
||||
|
||||
def test_suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
Loading…
Reference in New Issue
Block a user