[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testAttributePrincipalRoleManager.py:1.1.2.3 testPrincipalRoleManager.py:1.1.2.10
Nick Garcia
ngarcia@codeit.com
Sat, 9 Feb 2002 17:19:21 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv8008/lib/python/Zope/App/Security/tests
Modified Files:
Tag: Zope-3x-branch
testAttributePrincipalRoleManager.py
testPrincipalRoleManager.py
Log Message:
Added getPrincipalsAndRoles() to AttributePrincipalRoleManager and PrincipalRoleManager as well as the IPrincipalRoleMap interface, plus unit tests.
=== Zope3/lib/python/Zope/App/Security/tests/testAttributePrincipalRoleManager.py 1.1.2.2 => 1.1.2.3 ===
self.failUnless((prin2,Assign) in principals)
+ def testPrincipalsAndRoles(self):
+ principalRoleManager = AttributePrincipalRoleManager(Manageable())
+ principalsAndRoles = principalRoleManager.getPrincipalsAndRoles()
+ self.assertEqual(len(principalsAndRoles), 0)
+ role1 = rregistry.defineRole('Role One', 'Role #1').getId()
+ role2 = rregistry.defineRole('Role Two', 'Role #2').getId()
+ prin1 = self._make_principal()
+ prin2 = self._make_principal('Principal 2', 'Principal Two')
+ principalRoleManager.assignRoleToPrincipal(role1, prin1)
+ principalRoleManager.assignRoleToPrincipal(role1, prin2)
+ principalRoleManager.assignRoleToPrincipal(role2, prin1)
+ principalsAndRoles = principalRoleManager.getPrincipalsAndRoles()
+ self.assertEqual(len(principalsAndRoles), 3)
+ self.failUnless((role1,prin1,Assign) in principalsAndRoles)
+ self.failUnless((role1,prin2,Assign) in principalsAndRoles)
+ self.failUnless((role2,prin1,Assign) in principalsAndRoles)
+
+
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
=== Zope3/lib/python/Zope/App/Security/tests/testPrincipalRoleManager.py 1.1.2.9 => 1.1.2.10 ===
self.failUnless((prin2,Assign) in principals)
+ def testPrincipalsAndRoles(self):
+ role1 = rregistry.defineRole('Role One', 'Role #1').getId()
+ role2 = rregistry.defineRole('Role Two', 'Role #2').getId()
+ prin1 = self._make_principal()
+ prin2 = self._make_principal('Principal 2', 'Principal Two')
+ principalRoleManager.assignRoleToPrincipal(role1, prin1)
+ principalRoleManager.assignRoleToPrincipal(role1, prin2)
+ principalRoleManager.assignRoleToPrincipal(role2, prin1)
+ principalsAndRoles = principalRoleManager.getPrincipalsAndRoles()
+ self.assertEqual(len(principalsAndRoles), 3)
+ self.failUnless((role1,prin1,Assign) in principalsAndRoles)
+ self.failUnless((role1,prin2,Assign) in principalsAndRoles)
+ self.failUnless((role2,prin1,Assign) in principalsAndRoles)
+
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)