Esempio n. 1
0
 def test_roles_groups_for_user(self):
     """test groups_for() and roles_for()"""
     _ID = '*****@*****.**'
     _GROUP = 'testgroup1'
     adapter = SiteMembers(self.portal)
     adapter.register(_ID, send=False)
     self.groups_plugin.addGroup(_GROUP)
     self.groups_plugin.addPrincipalToGroup(_ID, _GROUP)
     self.assertIn(_GROUP, adapter.groups_for(_ID))
     self.assertIn('Member', adapter.roles_for(self.portal, _ID))
 def test_roles_groups_for_user(self):
     """test groups_for() and roles_for()"""
     _ID = '*****@*****.**'
     _GROUP = 'testgroup1'
     adapter = SiteMembers(self.portal)
     adapter.register(_ID, send=False)
     self.groups_plugin.addGroup(_GROUP)
     self.groups_plugin.addPrincipalToGroup(_ID, _GROUP)
     self.assertIn(_GROUP, adapter.groups_for(_ID))
     self.assertIn('Member', adapter.roles_for(self.portal, _ID))
Esempio n. 3
0
 def test_unknown_userid(self):
     # note: testing add/remove typically tests known user
     #       ids, the point of this test is to ensure the
     #       right things happen when an unknown user is used.
     unknown = '*****@*****.**'
     members = SiteMembers(self.portal)
     assert unknown not in members
     assert members.get(unknown) is None
     self.assertRaises(KeyError, lambda: members[unknown])
     self.assertRaises(KeyError, lambda: members.__delitem__(unknown))
     self.assertRaises(KeyError,
                       lambda: members.roles_for(self.portal, unknown))
     self.assertRaises(KeyError, lambda: members.groups_for(unknown))
 def test_unknown_userid(self):
     # note: testing add/remove typically tests known user
     #       ids, the point of this test is to ensure the
     #       right things happen when an unknown user is used.
     unknown = '*****@*****.**'
     members = SiteMembers(self.portal)
     assert unknown not in members
     assert members.get(unknown) is None
     self.assertRaises(KeyError, lambda: members[unknown])
     self.assertRaises(KeyError, lambda: members.__delitem__(unknown))
     self.assertRaises(
         KeyError,
         lambda: members.roles_for(self.portal, unknown)
         )
     self.assertRaises(KeyError, lambda: members.groups_for(unknown))