def test_update_role_settings(self):
     #context = None
     request = {}
     roles_view = RolesView(self.folder, request)
     new_settings = []
     reindex = False
     self.assertEqual(
         False, roles_view.update_role_settings(new_settings, reindex))
    def __iter__(self):
        for item in self.previous:
            pathkey = self.pathkey(*item.keys())[0]
            roleskey = self.roleskey(*item.keys())[0]

            if not pathkey or not roleskey or \
               roleskey not in item:    # not enough info
                yield item; continue

            obj = self.context.unrestrictedTraverse(item[pathkey].lstrip('/'), None)
            if obj is None:             # path doesn't exist
                yield item; continue

            if IRoleManager.providedBy(obj):
                new_settings = []
                groups = getToolByName(self.context, 'portal_groups')
                newrolemap = self.options.get('local-roles-mapping', {})
                if newrolemap:
                    newrolemap = newrolemap.split('\n')
                    newrolemap = dict([(t.split(':')[0].strip(),
                                     t.split(':')[1].strip())
                                 for t in newrolemap if ':' in t])
                for principal, roles in item[roleskey].items():
                    if roles:
                        if newrolemap:
                            roles = [newrolemap.get(r, r) for r in roles]
                        obj.manage_addLocalRoles(principal, roles)
                        obj.reindexObjectSecurity()
                        if HAS_GS:
                            new_settings.append({
                                'id': principal,
                                'type': groups.getGroupById(principal) and 'group' or 'user',
                                'roles': [r for r in roles if queryUtility(IRolesPageRole, r)],
                            })
                if HAS_GS and ILocalGroupSpacePASRoles.providedBy(obj):
                    roles_view = RolesView(obj, TestRequest())
                    roles_view.update_role_settings(new_settings)

            yield item