Whitespace.
svn path=/plone.app.discussion/trunk/; revision=49043
This commit is contained in:
parent
f551e30849
commit
521ea78ce3
@ -19,25 +19,22 @@ from plone.app.discussion.interfaces import IConversation
|
|||||||
|
|
||||||
|
|
||||||
class ModerationViewTest(unittest.TestCase):
|
class ModerationViewTest(unittest.TestCase):
|
||||||
|
|
||||||
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.app = self.layer['app']
|
self.app = self.layer['app']
|
||||||
self.portal = self.layer['portal']
|
self.portal = self.layer['portal']
|
||||||
self.request = self.layer['request']
|
self.request = self.layer['request']
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
|
|
||||||
typetool = self.portal.portal_types
|
typetool = self.portal.portal_types
|
||||||
typetool.constructContent('Document', self.portal, 'doc1')
|
typetool.constructContent('Document', self.portal, 'doc1')
|
||||||
|
|
||||||
self.portal_discussion = getToolByName(self.portal,
|
self.portal_discussion = getToolByName(self.portal,
|
||||||
'portal_discussion',
|
'portal_discussion',
|
||||||
None)
|
None)
|
||||||
self.membership_tool = getToolByName(self.portal,
|
self.membership_tool = getToolByName(self.portal,
|
||||||
'portal_membership')
|
'portal_membership')
|
||||||
self.memberdata = self.portal.portal_memberdata
|
self.memberdata = self.portal.portal_memberdata
|
||||||
|
|
||||||
request = self.app.REQUEST
|
request = self.app.REQUEST
|
||||||
context = getattr(self.portal, 'doc1')
|
context = getattr(self.portal, 'doc1')
|
||||||
self.view = View(context, request)
|
self.view = View(context, request)
|
||||||
@ -99,11 +96,8 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
|||||||
self.portal.portal_workflow.setChainForPortalTypes(
|
self.portal.portal_workflow.setChainForPortalTypes(
|
||||||
('Discussion Item',), 'comment_review_workflow')
|
('Discussion Item',), 'comment_review_workflow')
|
||||||
self.wf_tool = self.portal.portal_workflow
|
self.wf_tool = self.portal.portal_workflow
|
||||||
|
|
||||||
# Add a conversation with three comments
|
# Add a conversation with three comments
|
||||||
|
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
|
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.title = 'Comment 1'
|
comment1.title = 'Comment 1'
|
||||||
comment1.text = 'Comment text'
|
comment1.text = 'Comment text'
|
||||||
@ -111,7 +105,6 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
|||||||
new_id_1 = conversation.addComment(comment1)
|
new_id_1 = conversation.addComment(comment1)
|
||||||
self.comment1 = self.portal.doc1.restrictedTraverse(\
|
self.comment1 = self.portal.doc1.restrictedTraverse(\
|
||||||
'++conversation++default/%s' % new_id_1)
|
'++conversation++default/%s' % new_id_1)
|
||||||
|
|
||||||
comment2 = createObject('plone.Comment')
|
comment2 = createObject('plone.Comment')
|
||||||
comment2.title = 'Comment 2'
|
comment2.title = 'Comment 2'
|
||||||
comment2.text = 'Comment text'
|
comment2.text = 'Comment text'
|
||||||
@ -119,7 +112,6 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
|||||||
new_id_2 = conversation.addComment(comment2)
|
new_id_2 = conversation.addComment(comment2)
|
||||||
self.comment2 = self.portal.doc1.restrictedTraverse(\
|
self.comment2 = self.portal.doc1.restrictedTraverse(\
|
||||||
'++conversation++default/%s' % new_id_2)
|
'++conversation++default/%s' % new_id_2)
|
||||||
|
|
||||||
comment3 = createObject('plone.Comment')
|
comment3 = createObject('plone.Comment')
|
||||||
comment3.title = 'Comment 3'
|
comment3.title = 'Comment 3'
|
||||||
comment3.text = 'Comment text'
|
comment3.text = 'Comment text'
|
||||||
@ -127,21 +119,23 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
|||||||
new_id_3 = conversation.addComment(comment3)
|
new_id_3 = conversation.addComment(comment3)
|
||||||
self.comment3 = self.portal.doc1.restrictedTraverse(\
|
self.comment3 = self.portal.doc1.restrictedTraverse(\
|
||||||
'++conversation++default/%s' % new_id_3)
|
'++conversation++default/%s' % new_id_3)
|
||||||
|
|
||||||
self.conversation = conversation
|
self.conversation = conversation
|
||||||
|
|
||||||
def test_default_bulkaction(self):
|
def test_default_bulkaction(self):
|
||||||
# Make sure no error is raised when no bulk actions has been supplied
|
# Make sure no error is raised when no bulk actions has been supplied
|
||||||
self.request.set('form.select.BulkAction', '-1')
|
self.request.set('form.select.BulkAction', '-1')
|
||||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
||||||
|
|
||||||
view = BulkActionsView(self.portal, self.request)
|
view = BulkActionsView(self.portal, self.request)
|
||||||
|
|
||||||
self.assertFalse(view())
|
self.assertFalse(view())
|
||||||
|
|
||||||
def test_retract(self):
|
def test_retract(self):
|
||||||
self.request.set('form.select.BulkAction', 'retract')
|
self.request.set('form.select.BulkAction', 'retract')
|
||||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
||||||
|
|
||||||
view = BulkActionsView(self.portal, self.request)
|
view = BulkActionsView(self.portal, self.request)
|
||||||
|
|
||||||
self.assertRaises(NotImplementedError,
|
self.assertRaises(NotImplementedError,
|
||||||
view)
|
view)
|
||||||
|
|
||||||
@ -149,8 +143,9 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
|||||||
self.request.set('form.select.BulkAction', 'publish')
|
self.request.set('form.select.BulkAction', 'publish')
|
||||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
||||||
view = BulkActionsView(self.portal, self.request)
|
view = BulkActionsView(self.portal, self.request)
|
||||||
|
|
||||||
view()
|
view()
|
||||||
|
|
||||||
# Count published comments
|
# Count published comments
|
||||||
published_comments = 0
|
published_comments = 0
|
||||||
for r in self.conversation.getThreads():
|
for r in self.conversation.getThreads():
|
||||||
@ -158,30 +153,29 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
|||||||
workflow_status = self.wf.getInfoFor(comment_obj, 'review_state')
|
workflow_status = self.wf.getInfoFor(comment_obj, 'review_state')
|
||||||
if workflow_status == 'published':
|
if workflow_status == 'published':
|
||||||
published_comments += 1
|
published_comments += 1
|
||||||
|
|
||||||
# Make sure the comment has been published
|
# Make sure the comment has been published
|
||||||
self.assertEqual(published_comments, 1)
|
self.assertEqual(published_comments, 1)
|
||||||
|
|
||||||
def test_mark_as_spam(self):
|
def test_mark_as_spam(self):
|
||||||
self.request.set('form.select.BulkAction', 'mark_as_spam')
|
self.request.set('form.select.BulkAction', 'mark_as_spam')
|
||||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
||||||
|
|
||||||
view = BulkActionsView(self.portal, self.request)
|
view = BulkActionsView(self.portal, self.request)
|
||||||
|
|
||||||
self.assertRaises(NotImplementedError,
|
self.assertRaises(NotImplementedError,
|
||||||
view)
|
view)
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
# Initially we have three comments
|
# Initially we have three comments
|
||||||
self.assertEqual(self.conversation.total_comments, 3)
|
self.assertEqual(self.conversation.total_comments, 3)
|
||||||
|
|
||||||
# Delete two comments with bulk actions
|
# Delete two comments with bulk actions
|
||||||
self.request.set('form.select.BulkAction', 'delete')
|
self.request.set('form.select.BulkAction', 'delete')
|
||||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath()),
|
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath()),
|
||||||
'/'.join(self.comment3.getPhysicalPath())])
|
'/'.join(self.comment3.getPhysicalPath())])
|
||||||
view = BulkActionsView(self.app, self.request)
|
view = BulkActionsView(self.app, self.request)
|
||||||
|
|
||||||
view()
|
view()
|
||||||
|
|
||||||
# Make sure that the two comments have been deleted
|
# Make sure that the two comments have been deleted
|
||||||
self.assertEqual(self.conversation.total_comments, 1)
|
self.assertEqual(self.conversation.total_comments, 1)
|
||||||
comment = self.conversation.getComments().next()
|
comment = self.conversation.getComments().next()
|
||||||
|
Loading…
Reference in New Issue
Block a user