Some more tests for moderation bulk actions.

svn path=/plone.app.discussion/trunk/; revision=39945
This commit is contained in:
Timo Stollenwerk 2010-09-16 15:42:27 +00:00
parent 742412a7d8
commit e8a4caa5db
2 changed files with 24 additions and 6 deletions

View File

@ -22,13 +22,13 @@ from plone.app.discussion.interfaces import IComment
# Bug report: https://bugs.launchpad.net/zope2/+bug/176566 # Bug report: https://bugs.launchpad.net/zope2/+bug/176566
# #
def _getContext(self): # pragma: no cover def _getContext(self): # pragma: no cover
self = self.aq_parent self = self.aq_parent # pragma: no cover
while getattr(self, '_is_wrapperish', None): while getattr(self, '_is_wrapperish', None): # pragma: no cover
self = self.aq_parent self = self.aq_parent # pragma: no cover
return self return self # pragma: no cover
ZopeTwoPageTemplateFile._getContext = _getContext ZopeTwoPageTemplateFile._getContext = _getContext # pragma: no cover
# End ugly hack. # End ugly hack.

View File

@ -143,11 +143,27 @@ class ModerationBulkActionsViewTest(PloneTestCase):
self.conversation = conversation self.conversation = conversation
def test_default_bulkaction(self):
self.request = self.app.REQUEST
self.context = self.portal
self.request.set('form.select.BulkAction', '-1')
view = BulkActionsView(self.context, self.request)
self.failIf(view())
def test_wrong_bulkaction(self):
self.request = self.app.REQUEST
self.context = self.portal
self.request.set('form.select.BulkAction', 'stupid')
view = BulkActionsView(self.context, self.request)
self.assertRaises(TypeError,
view)
def test_retract(self): def test_retract(self):
self.request = self.app.REQUEST self.request = self.app.REQUEST
self.context = self.portal self.context = self.portal
self.request.set('form.select.BulkAction', 'retract') self.request.set('form.select.BulkAction', 'retract')
view = BulkActionsView(self.context, self.request) view = BulkActionsView(self.context, self.request)
view()
self.assertRaises(NotImplementedError, self.assertRaises(NotImplementedError,
view.retract) view.retract)
@ -168,6 +184,7 @@ class ModerationBulkActionsViewTest(PloneTestCase):
if workflow_status == 'published': if workflow_status == 'published':
published_comments += 1 published_comments += 1
# Make sure the comment has been published
self.assertEquals(published_comments, 1) self.assertEquals(published_comments, 1)
def test_mark_as_spam(self): def test_mark_as_spam(self):
@ -175,6 +192,7 @@ class ModerationBulkActionsViewTest(PloneTestCase):
self.context = self.portal self.context = self.portal
self.request.set('form.select.BulkAction', 'mark_as_spam') self.request.set('form.select.BulkAction', 'mark_as_spam')
view = BulkActionsView(self.context, self.request) view = BulkActionsView(self.context, self.request)
view()
self.assertRaises(NotImplementedError, self.assertRaises(NotImplementedError,
view.mark_as_spam) view.mark_as_spam)