Exemplo n.º 1
0
 def test_ExtraSuffixesForFinanceOrgs(self):
     """Finances related organizations get extra suffixes."""
     self.changeUser('admin')
     self._createFinanceGroups()
     vendorsPloneGroupIds = get_plone_groups(self.vendors_uid, ids_only=True)
     vendorsPloneGroupIds.sort()
     self.assertEqual(vendorsPloneGroupIds,
                      ['{0}_administrativereviewers'.format(self.vendors_uid),
                       '{0}_advisers'.format(self.vendors_uid),
                       '{0}_creators'.format(self.vendors_uid),
                       '{0}_incopy'.format(self.vendors_uid),
                       '{0}_internalreviewers'.format(self.vendors_uid),
                       '{0}_observers'.format(self.vendors_uid),
                       '{0}_prereviewers'.format(self.vendors_uid),
                       '{0}_reviewers'.format(self.vendors_uid)])
     financial_group_uids = self.tool.finance_group_uids()
     financeGroupUID = financial_group_uids[0]
     financePloneGroupIds = get_plone_groups(financeGroupUID, ids_only=True)
     financePloneGroupIds.sort()
     self.assertEqual(financePloneGroupIds,
                      ['{0}_administrativereviewers'.format(financeGroupUID),
                       '{0}_advisers'.format(financeGroupUID),
                       '{0}_creators'.format(financeGroupUID),
                       '{0}_financialcontrollers'.format(financeGroupUID),
                       '{0}_financialmanagers'.format(financeGroupUID),
                       '{0}_financialreviewers'.format(financeGroupUID),
                       '{0}_incopy'.format(financeGroupUID),
                       '{0}_internalreviewers'.format(financeGroupUID),
                       '{0}_observers'.format(financeGroupUID),
                       '{0}_prereviewers'.format(financeGroupUID),
                       '{0}_reviewers'.format(financeGroupUID)])
Exemplo n.º 2
0
    def _setupForOrgs(self, number_of_orgs):
        self.changeUser('admin')
        cfg = self.meetingConfig
        cfg2 = self.meetingConfig2
        # remove existing groups and add our own
        # make what necessary for groups to be removable...
        cfg.setOrderedGroupsInCharge(())
        cfg.setSelectableCopyGroups(())
        cfg.setSelectableAdvisers(())
        cfg2.setOrderedGroupsInCharge(())
        cfg2.setSelectableCopyGroups(())
        cfg2.setSelectableAdvisers(())
        orgs = get_organizations(only_selected=True)
        for org in orgs:
            self._select_organization(org.UID(), remove=True)
            for ploneGroup in get_plone_groups(org.UID()):
                for memberId in ploneGroup.getGroupMemberIds():
                    ploneGroup.removeMember(memberId)
        # remove items defined in the tool
        self._removeConfigObjectsFor(cfg, folders=['recurringitems', 'itemtemplates', 'categories'])
        self._removeConfigObjectsFor(cfg2, folders=['recurringitems', 'itemtemplates', 'categories'])

        # remove groups
        self._removeOrganizations()
        # create groups
        for i in range(number_of_orgs):
            org = self.create('organization', id=i, title='Org %d' % i)
            self._select_organization(org.UID())
Exemplo n.º 3
0
 def test_get_plone_groups(self):
     plone_groups = [
         get_plone_group(self.uid, 'observer'),
         get_plone_group(self.uid, 'director')
     ]
     self.assertEqual(get_plone_groups(self.uid, ids_only=False),
                      plone_groups)
     self.assertEqual(get_plone_groups(self.uid, ids_only=True),
                      [g.id for g in plone_groups])
     self.assertEqual(get_plone_groups(self.uid, suffixes=['observer']),
                      [plone_groups[0]])
     self.assertEqual(
         get_plone_groups(self.uid, suffixes=['unknown_suffix']), [])
     self.assertEqual(
         get_plone_groups(self.uid,
                          ids_only=True,
                          suffixes=['unknown_suffix']), [])
Exemplo n.º 4
0
 def _removeOrganizations(self):
     """Delete every organizations found in own_org."""
     # remove every users from linked Plone groups so organizations are removable
     for org in self.own_org.objectValues():
         plone_groups = get_plone_groups(org.UID())
         for plone_group in plone_groups:
             for member_id in plone_group.getMemberIds():
                 self.portal.portal_groups.removePrincipalFromGroup(member_id, plone_group.id)
         # empty groups_in_charge
         org.groups_in_charge = []
     # unselect every organizations from plonegroup
     api.portal.set_registry_record(ORGANIZATIONS_REGISTRY, [])
     ids_to_remove = self.own_org.objectIds()
     self.own_org.manage_delObjects(ids=ids_to_remove)
     self.cleanMemoize()
Exemplo n.º 5
0
    def setUp(self):
        # enable full diff in failing tests
        self.maxDiff = None
        # Define some useful attributes
        self.app = self.layer['app']
        self.portal = self.layer['portal']
        self.request = self.layer['request']
        self.changeUser('admin')
        # setup manually the correct browserlayer, see:
        # https://dev.plone.org/ticket/11673
        notify(BeforeTraverseEvent(self.portal, self.request))
        self.tool = self.portal.portal_plonemeeting
        self.catalog = self.portal.portal_catalog
        self.wfTool = self.portal.portal_workflow
        self.own_org = get_own_organization()
        # make organizations easily available thru their id and store uid
        # for each organization, we will have self.developers, self.developers_uid
        # as well as every plone groups : self.vendors_creators, self.developers_reviewers, ...
        # include organizations outside own_org as well
        orgs = object_values(self.own_org, 'PMOrganization') + \
            object_values(self.own_org.aq_parent, 'PMOrganization')
        for org in orgs:
            setattr(self, org.getId(), org)
            setattr(self, '{0}_uid'.format(org.getId()), org.UID())
            for plone_group_id in get_plone_groups(org.UID(), ids_only=True):
                org_uid, suffix = plone_group_id.split('_')
                setattr(self,
                        '{0}_{1}'.format(org.getId(), suffix),
                        plone_group_id)
        # make held_position easily available as well
        i = 1
        for person in object_values(self.portal.contacts, 'PMPerson'):
            setattr(self,
                    'hp{0}'.format(i),
                    object_values(person, 'PMHeldPosition')[0])
            setattr(self,
                    'hp{0}_uid'.format(i),
                    object_values(person, 'PMHeldPosition')[0].UID())
            i += 1

        self.pmFolder = os.path.dirname(Products.PloneMeeting.__file__)
        # Disable notifications mechanism. This way, the test suite may be
        # executed even on production sites that contain many real users.
        for cfg in self.tool.objectValues('MeetingConfig'):
            cfg.setMailItemEvents([])
            cfg.setMailMeetingEvents([])
        logout()

        # Set the default meeting config
        self.meetingConfig = getattr(self.tool, self.cfg1_id, None)
        self.meetingConfig2 = getattr(self.tool, self.cfg2_id, None)
        # Set the default file and file type for adding annexes
        self.annexFile = u'FILE.txt'
        self.annexFilePDF = u'file_correct.pdf'
        self.annexFileCorruptedPDF = u'file_errorDuringConversion.pdf'
        self.annexFileType = 'financial-analysis'
        self.annexFileTypeDecision = 'decision-annex'
        self.annexFileTypeAdvice = 'advice-annex'
        self.annexFileTypeMeeting = 'meeting-annex'
        # log current test module and method name
        test_num = self._resultForDoCleanups.testsRun
        test_total = self._resultForDoCleanups.count
        pm_logger.info('Executing [{0}/{1}] {2}:{3}'.format(
            test_num, test_total, self.__class__.__name__, self._testMethodName))