class ModerationViewTest(unittest.TestCase): layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING def setUp(self): self.app = self.layer["app"] self.portal = self.layer["portal"] self.request = self.layer["request"] setRoles(self.portal, TEST_USER_ID, ["Manager"]) typetool = self.portal.portal_types typetool.constructContent("Document", self.portal, "doc1") self.portal_discussion = getToolByName(self.portal, "portal_discussion", None) self.membership_tool = getToolByName(self.portal, "portal_membership") self.memberdata = self.portal.portal_memberdata request = self.app.REQUEST context = getattr(self.portal, "doc1") self.view = View(context, request) self.view.__of__(context) self.portal.portal_workflow.setChainForPortalTypes(("Discussion Item",), "comment_review_workflow") self.wf_tool = self.portal.portal_workflow def test_moderation_enabled(self): """Make sure that moderation_enabled returns true if the comment workflow implements a 'pending' state. """ # If workflow is not set, enabled must return False self.wf_tool.setChainForPortalTypes(("Discussion Item",), ()) self.assertEqual(self.view.moderation_enabled(), False) # The one_state_workflow does not have a 'pending' state self.wf_tool.setChainForPortalTypes(("Discussion Item",), ("one_state_workflow,")) self.assertEqual(self.view.moderation_enabled(), False) # The comment_review_workflow does have a 'pending' state self.wf_tool.setChainForPortalTypes(("Discussion Item",), ("comment_review_workflow,")) self.assertEqual(self.view.moderation_enabled(), True)
class ModerationViewTest(unittest.TestCase): layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING def setUp(self): self.app = self.layer['app'] self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.portal_discussion = getToolByName(self.portal, 'portal_discussion', None) self.membership_tool = getToolByName(self.portal, 'portal_membership') self.memberdata = self.portal.portal_memberdata 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 def test_moderation_enabled(self): """Make sure that moderation_enabled returns true if the comment workflow implements a 'pending' state. """ # If workflow is not set, enabled must return False self.wf_tool.setChainForPortalTypes(('Discussion Item', ), ()) self.assertEqual(self.view.moderation_enabled(), False) # The comment_one_state_workflow does not have a 'pending' state self.wf_tool.setChainForPortalTypes(('Discussion Item', ), ('comment_one_state_workflow,')) self.assertEqual(self.view.moderation_enabled(), False) # The comment_review_workflow does have a 'pending' state self.wf_tool.setChainForPortalTypes(('Discussion Item', ), ('comment_review_workflow,')) self.assertEqual(self.view.moderation_enabled(), True)
def setUp(self): self.app = self.layer['app'] self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.portal_discussion = getToolByName(self.portal, 'portal_discussion', None) self.membership_tool = getToolByName(self.portal, 'portal_membership') self.memberdata = self.portal.portal_memberdata 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
class ModerationViewTest(unittest.TestCase): layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING def setUp(self): self.app = self.layer['app'] self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.portal_discussion = getToolByName(self.portal, 'portal_discussion', None) self.membership_tool = getToolByName(self.portal, 'portal_membership') self.memberdata = self.portal.portal_memberdata request = self.app.REQUEST context = getattr(self.portal, 'doc1') self.view = View(context, request) self.view.__of__(context) self.portal.portal_workflow.setChainForPortalTypes( ('Discussion Item',), 'comment_review_workflow') self.wf_tool = self.portal.portal_workflow def test_moderation_enabled(self): """Make sure that moderation_enabled returns true if the comment workflow implements a 'pending' state. """ # If workflow is not set, enabled must return False self.wf_tool.setChainForPortalTypes(('Discussion Item',), ()) self.assertEqual(self.view.moderation_enabled(), False) # The one_state_workflow does not have a 'pending' state self.wf_tool.setChainForPortalTypes(('Discussion Item',), ('one_state_workflow,')) self.assertEqual(self.view.moderation_enabled(), False) # The comment_review_workflow does have a 'pending' state self.wf_tool.setChainForPortalTypes(('Discussion Item',), ('comment_review_workflow,')) self.assertEqual(self.view.moderation_enabled(), True)
def setUp(self): self.app = self.layer["app"] self.portal = self.layer["portal"] self.request = self.layer["request"] setRoles(self.portal, TEST_USER_ID, ["Manager"]) self.portal_discussion = getToolByName(self.portal, "portal_discussion", None) self.membership_tool = getToolByName(self.portal, "portal_membership") self.memberdata = self.portal.portal_memberdata request = self.app.REQUEST context = getattr(self.portal, "doc1") self.view = View(context, request) self.view.__of__(context) self.portal.portal_workflow.setChainForPortalTypes(("Discussion Item",), "comment_review_workflow") self.wf_tool = self.portal.portal_workflow
def setUp(self): self.app = self.layer['app'] self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.portal_discussion = getToolByName(self.portal, 'portal_discussion', None) self.membership_tool = getToolByName(self.portal, 'portal_membership') self.memberdata = self.portal.portal_memberdata 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
class ModerationViewTest(unittest.TestCase): layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING def setUp(self): self.app = self.layer['app'] self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) typetool = self.portal.portal_types typetool.constructContent('Document', self.portal, 'doc1') self.portal_discussion = getToolByName(self.portal, 'portal_discussion', None) self.membership_tool = getToolByName(self.portal, 'portal_membership') self.memberdata = self.portal.portal_memberdata request = self.app.REQUEST context = getattr(self.portal, 'doc1') self.view = View(context, request) self.view.__of__(context) self.portal.portal_workflow.setChainForPortalTypes( ('Discussion Item', ), 'comment_review_workflow') self.wf_tool = self.portal.portal_workflow def test_moderation_enabled(self): """Make sure that moderation_enabled returns true if the comment workflow implements a 'pending' state. """ # If workflow is not set, enabled must return False self.wf_tool.setChainForPortalTypes(('Discussion Item', ), ()) self.assertEqual(self.view.moderation_enabled(), False) # The one_state_workflow does not have a 'pending' state self.wf_tool.setChainForPortalTypes(('Discussion Item', ), ('one_state_workflow,')) self.assertEqual(self.view.moderation_enabled(), False) # The comment_review_workflow does have a 'pending' state self.wf_tool.setChainForPortalTypes(('Discussion Item', ), ('comment_review_workflow,')) self.assertEqual(self.view.moderation_enabled(), True) def test_old_comments_not_shown_in_moderation_view(self): # Create old comment discussion = getToolByName(self.portal, 'portal_discussion', None) discussion.overrideDiscussionFor(self.portal.doc1, 1) talkback = discussion.getDiscussionFor(self.portal.doc1) self.portal.doc1.talkback.createReply('My Title', 'My Text', Creator='Jim') reply = talkback.getReplies()[0] reply.setReplyTo(self.portal.doc1) reply.creation_date = DateTime(2003, 3, 11, 9, 28, 6) reply.modification_date = DateTime(2009, 7, 12, 19, 38, 7) self.assertEqual(reply.Title(), 'My Title') self.assertEqual(reply.EditableBody(), 'My Text') self.assertTrue('Jim' in reply.listCreators()) self.assertEqual(talkback.replyCount(self.portal.doc1), 1) self.assertEqual(reply.inReplyTo(), self.portal.doc1) view = self.view() self.assertTrue('No comments to moderate' in view) self.assertEqual(len(self.view.comments), 0)
class ModerationViewTest(unittest.TestCase): layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING def setUp(self): self.app = self.layer['app'] self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) typetool = self.portal.portal_types typetool.constructContent('Document', self.portal, 'doc1') self.portal_discussion = getToolByName(self.portal, 'portal_discussion', None) self.membership_tool = getToolByName(self.portal, 'portal_membership') self.memberdata = self.portal.portal_memberdata request = self.app.REQUEST context = getattr(self.portal, 'doc1') self.view = View(context, request) self.view.__of__(context) self.portal.portal_workflow.setChainForPortalTypes( ('Discussion Item',), 'comment_review_workflow') self.wf_tool = self.portal.portal_workflow def test_moderation_enabled(self): """Make sure that moderation_enabled returns true if the comment workflow implements a 'pending' state. """ # If workflow is not set, enabled must return False self.wf_tool.setChainForPortalTypes(('Discussion Item',), ()) self.assertEqual(self.view.moderation_enabled(), False) # The one_state_workflow does not have a 'pending' state self.wf_tool.setChainForPortalTypes(('Discussion Item',), ('one_state_workflow,')) self.assertEqual(self.view.moderation_enabled(), False) # The comment_review_workflow does have a 'pending' state self.wf_tool.setChainForPortalTypes(('Discussion Item',), ('comment_review_workflow,')) self.assertEqual(self.view.moderation_enabled(), True) def test_old_comments_not_shown_in_moderation_view(self): # Create old comment discussion = getToolByName(self.portal, 'portal_discussion', None) discussion.overrideDiscussionFor(self.portal.doc1, 1) talkback = discussion.getDiscussionFor(self.portal.doc1) self.portal.doc1.talkback.createReply('My Title', 'My Text', Creator='Jim') reply = talkback.getReplies()[0] reply.setReplyTo(self.portal.doc1) reply.creation_date = DateTime(2003, 3, 11, 9, 28, 6) reply.modification_date = DateTime(2009, 7, 12, 19, 38, 7) self.assertEqual(reply.Title(), 'My Title') self.assertEqual(reply.EditableBody(), 'My Text') self.assertTrue('Jim' in reply.listCreators()) self.assertEqual(talkback.replyCount(self.portal.doc1), 1) self.assertEqual(reply.inReplyTo(), self.portal.doc1) view = self.view() self.assertTrue('No comments to moderate' in view) self.assertEqual(len(self.view.comments), 0)