コード例 #1
0
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']

        self.uf = self.portal.acl_users
        self.basic = basic_auth_encode(TEST_USER_NAME, TEST_USER_PASSWORD)

        _createMemberarea(self.portal, TEST_USER_ID)
        self.folder = self.portal.portal_membership.getHomeFolder(TEST_USER_ID)

        # Set up a published object accessible to the default user
        self.folder.addDTMLMethod('doc', file='')
        self.folder.doc.manage_permission('View', [user_role], acquire=0)
        # Rig the REQUEST so it looks like we traversed to 'doc'
        self.request.set('PUBLISHED', self.folder['doc'])
        self.request.set('PARENTS', [self.folder, self.portal])
        folder_path = list(self.folder.getPhysicalPath())
        self.request.steps = folder_path + ['doc']

        if 'auto_group' in self.uf:
            self.uf.manage_delObjects(['auto_group'])

        # Nuke Administators and Reviewers groups added in 2.1a2 migrations
        # (and any other migrated-in groups) to avoid test confusion
        self.portal.portal_groups.removeGroups(
            self.portal.portal_groups.listGroupIds())

        login(self.portal, TEST_USER_NAME)
        setRoles(self.portal, TEST_USER_ID, [
            user_role,
        ])
コード例 #2
0
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']

        self.uf = self.portal.acl_users
        self.basic = \
            'Basic %s' % base64.encodestring(
                '%s:%s' % (TEST_USER_NAME, TEST_USER_PASSWORD))

        _createMemberarea(self.portal, TEST_USER_ID)
        self.folder = self.portal.portal_membership.getHomeFolder(TEST_USER_ID)

        # Set up a published object accessible to the default user
        self.folder.addDTMLMethod('doc', file='')
        self.folder.doc.manage_permission('View', [user_role], acquire=0)
        # Rig the REQUEST so it looks like we traversed to 'doc'
        self.request.set('PUBLISHED', self.folder['doc'])
        self.request.set('PARENTS', [self.folder, self.portal])
        folder_path = list(self.folder.getPhysicalPath())
        self.request.steps = folder_path + ['doc']

        if 'auto_group' in self.uf:
            self.uf.manage_delObjects(['auto_group'])

        # Nuke Administators and Reviewers groups added in 2.1a2 migrations
        # (and any other migrated-in groups) to avoid test confusion
        self.portal.portal_groups.removeGroups(
            self.portal.portal_groups.listGroupIds())

        login(self.portal, TEST_USER_NAME)
        setRoles(self.portal, TEST_USER_ID, [user_role, ])
コード例 #3
0
 def setUpBourgmestreConfig(self):
     """Setup meeting-config-bourgmestre :
        - Create groups and users;
        - ...
     """
     self.changeUser('siteadmin')
     self._createFinanceGroups()
     self.setMeetingConfig(self.meetingConfig3.getId())
     context = self.portal.portal_setup._getImportContext(
         'Products.MeetingLiege:testing')
     initializer = ToolInitializer(context, PROJECTNAME)
     orgs, active_orgs, savedOrgsData = initializer.addOrgs(
         bg_import_data.orgs)
     for org in orgs:
         self._select_organization(org.UID())
     initializer.addUsers(bg_import_data.orgs)
     initializer.addUsersOutsideGroups(
         bg_import_data.data.usersOutsideGroups)
     for userId in ('pmMeetingManagerBG', 'generalManager',
                    'bourgmestreManager', 'bourgmestreReviewer'):
         _createMemberarea(self.portal, userId)
     cfg = self.meetingConfig
     cfg.setUsedAdviceTypes(cfg.getUsedAdviceTypes() + ('asked_again', ))
     cfg.setItemAdviceStates(('proposed_to_director_waiting_advices', ))
     cfg.setItemAdviceEditStates = ((
         'proposed_to_director_waiting_advices', ))
     cfg.setKeepAccessToItemWhenAdvice('is_given')
コード例 #4
0
 def setUpPloneSite(self, portal):
     setLocal('request', portal.REQUEST)
     # configure default workflows so Folder has a workflow
     # make sure we have a default workflow
     portal.portal_workflow.setDefaultChain('simple_publication_workflow')
     super(PMLayer, self).setUpPloneSite(portal)
     # Create member area of existing users
     for user in api.user.get_users():
         # this layer is used by imio.pm.wsclient
         _createMemberarea(portal, user.getId())
コード例 #5
0
 def createUser(self, username, roles=['Member'], groups=[]):
     '''Creates a user named p_username with some p_roles.'''
     newUser = api.user.create(
         email='*****@*****.**',
         username=username,
         password=DEFAULT_USER_PASSWORD,
         roles=[],
         properties={})
     setRoles(self.portal, username, roles)
     for group in groups:
         self._addPrincipalToGroup(username, group)
     _createMemberarea(self.portal, username)
     return newUser
 def setUp(self):
     """ The setup steps below are only needed in Plone 5,
     because in Plone 4 they are taken care of automatically
     by PloneTestCase.
     """
     if IS_PLONE_5:
         self.portal = self.layer['portal']
         setRoles(self.portal, TEST_USER_ID, ['Manager'])
         _createMemberarea(self.portal, TEST_USER_ID)
         self.folder = self.portal.portal_membership.getHomeFolder(TEST_USER_ID)
         transaction.commit()
         self.afterSetUp()
     else:
         super(TestMailAction, self).setUp()
コード例 #7
0
 def setUp(self):
     """ The setup steps below are only needed in Plone 5,
     because in Plone 4 they are taken care of automatically
     by PloneTestCase.
     """
     if IS_PLONE_5:
         self.portal = self.layer['portal']
         setRoles(self.portal, TEST_USER_ID, ['Manager'])
         _createMemberarea(self.portal, TEST_USER_ID)
         self.folder = self.portal.portal_membership.getHomeFolder(
             TEST_USER_ID)
         transaction.commit()
         self.afterSetUp()
     else:
         super(TestMailAction, self).setUp()