def test_pruneMemberData(self): # This needs a tad more setup from OFS.Folder import Folder from Products.CMFCore.MembershipTool import MembershipTool folder = Folder('test') folder._setObject('portal_memberdata', self._makeOne()) folder._setObject('portal_membership', MembershipTool()) folder._setObject('acl_users', DummyUserFolder()) tool = folder.portal_memberdata # Create some members for i in range(20): tool.registerMemberData('Dummy_%i' % i, 'user_foo_%i' % i) # None of these fake members are in the user folder, which means # there are 20 members and 20 "orphans" contents = tool.getMemberDataContents() info_dict = contents[0] self.assertEqual(info_dict['member_count'], 20) self.assertEqual(info_dict['orphan_count'], 20) # Calling the prune method should delete all orphans, so we end # up with no members in the tool. tool.pruneMemberDataContents() contents = tool.getMemberDataContents() info_dict = contents[0] self.assertEqual(info_dict['member_count'], 0) self.assertEqual(info_dict['orphan_count'], 0)
def listMembers(self): '''Gets the list of all members. THIS METHOD MIGHT BE VERY EXPENSIVE ON LARGE USER FOLDERS AND MUST BE USED WITH CARE! We plan to restrict its use in the future (ie. force large requests to use searchForMembers instead of listMembers, so that it will not be possible anymore to have a method returning several hundred of users :) ''' return BaseTool.listMembers(self)
def setUp(self): SecurityRequestTest.setUp(self) root = self.root root._setObject( 'portal_actions', self._makeOne() ) root._setObject( 'portal_url', URLTool() ) root._setObject( 'foo', URLTool() ) root._setObject('portal_membership', MembershipTool()) self.tool = root.portal_actions self.tool.action_providers = ('portal_actions',)
def setUp(self): from OFS.Folder import Folder from Products.CMFCore.MemberDataTool import MemberDataTool from Products.CMFCore.MembershipTool import MembershipTool self.site = Folder('test') self.site._setObject('portal_memberdata', MemberDataTool()) sm = getSiteManager() sm.registerUtility(MembershipTool(), IMembershipTool) self.site._setObject('acl_users', DummyUserFolder())
def setUp(self): from Products.CMFCore.interfaces import IActionsTool SecurityTest.setUp(self) self.tool = self._makeOne() self.tool.action_providers = ('portal_actions', ) self.app._setObject('foo', URLTool()) sm = getSiteManager() sm.registerUtility(self.tool, IActionsTool) sm.registerUtility(MembershipTool(), IMembershipTool) sm.registerUtility(self.app, ISiteRoot) sm.registerUtility(URLTool(), IURLTool)
def setUp(self): SecurityRequestTest.setUp(self) root = self.root sm = getSiteManager() sm.registerUtility(root, ISiteRoot) root._setObject('portal_actions', self._makeOne()) root._setObject('portal_url', URLTool()) root._setObject('foo', URLTool()) root._setObject('portal_membership', MembershipTool()) self.tool = root.portal_actions self.tool.action_providers = ('portal_actions', )
def setUp(self): SecurityRequestTest.setUp(self) root = self.root root._setObject('portal_actions', ActionsTool()) root._setObject('foo', URLTool()) root._setObject('bar', URLTool()) root._setObject('portal_membership', MembershipTool()) root._setObject('portal_types', TypesTool()) self.tool = root.portal_actions self.ut = root.foo self.tool.action_providers = ('portal_actions', )
def _makeOne(self, *args, **kw): from Products.CMFCore.MembershipTool import MembershipTool return MembershipTool(*args, **kw)
def setUp(self): SecurityTest.setUp(self) self.site = DummySite('site').__of__(self.root) self.mtool = MembershipTool().__of__(self.site)