コード例 #1
0
 def testActionSummary(self):
     e = GroupAction()
     e.groupid = '${title}'
     e.grouptitle = 'Group of Contributors for folder ${title}'
     e.roles = set(['Contributor', ])
     summary = u'Create an user group ${groupid} with roles ${roles}'
     self.assertEqual(summary, e.summary)
コード例 #2
0
    def testExecute(self):
        e = GroupAction()
        e.groupid = 'New Group'
        e.grouptitle = 'Newly Created Group'
        e.roles = set(['Member', ])

        ex = getMultiAdapter(
            (self.portal, e, DummyEvent(self.folder)), IExecutable)
        self.assertEqual(True, ex())
        group = self.gt.getGroupById(e.groupid)
        self.assertTrue(group)
コード例 #3
0
    def testExecuteWithError(self):
        ''' Already a group with the same id '''
        e = GroupAction()
        e.groupid = 'Fav Customer'
        e.grouptitle = 'Our Fav Customer'
        e.roles = set(['Member', ])

        ex = getMultiAdapter(
            (self.portal, e, DummyEvent(self.folder)), IExecutable)

        self.assertFalse(ex())
コード例 #4
0
    def testExecuteWithoutGroupTool(self):
        ''' Test what happens if portal_groups is not available '''
        # Remove portal_tool
        self.portal._delOb('portal_groups')

        # Execute action
        e = GroupAction()
        e.groupid = 'New Group'
        e.grouptitle = 'Newly Created Group'
        e.roles = set(['Member', ])

        ex = getMultiAdapter(
            (self.portal, e, DummyEvent(self.folder)), IExecutable)
        self.assertFalse(ex())
コード例 #5
0
    def testExecuteWithoutGroupManagementPlugin(self):
        ''' No group management plugins enabled '''
        from Products.PlonePAS.interfaces.group import IGroupManagement
        # Disable group management plugins
        acl_users = getToolByName(self.portal, 'acl_users')
        acl_users.plugins.deactivatePlugin(IGroupManagement, 'source_groups')
        # Execute action
        e = GroupAction()
        e.groupid = 'New Group'
        e.grouptitle = 'Newly Created Group'
        e.roles = set(['Member', ])

        ex = getMultiAdapter(
            (self.portal, e, DummyEvent(self.folder)), IExecutable)
        self.assertEqual(False, ex())
コード例 #6
0
    def testExecuteInterp(self):
        # Setup scenario
        self.portal.invokeFactory('Folder', 'customer', title='Customer')
        folder = self.portal['customer']
        e = GroupAction()
        e.groupid = '${title}'
        e.grouptitle = 'Group of Contributors for folder ${title}'
        e.roles = set(['Contributor', ])

        ex = getMultiAdapter(
            (self.portal, e, DummyEvent(folder)), IExecutable)
        self.assertEqual(True, ex())
        group = self.gt.getGroupById(folder.Title())
        self.assertTrue(group)
        self.assertEqual(group.getGroupId(), folder.Title())
        grouptitle = 'Group of Contributors for folder %s' % folder.Title()
        self.assertEqual(group.getGroupTitleOrName(), grouptitle)