[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testAttributePrincipalPermissionManager.py:1.1.2.1.2.1

Jim Fulton jim@zope.com
Mon, 11 Feb 2002 10:05:40 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv15149

Modified Files:
      Tag: Zope-3x-security_defactor-branch
	testAttributePrincipalPermissionManager.py 
Log Message:
Changed tests (back) to use ids, rather than objects in security
assertions. 

I'm in the process of changing all the security tests to use ids in
security assertions. The plan is to change and check in all the tests
and then to work together on making them pass again. When this is
done, we'll merge the changes back into the 3x branch.

Note that there might be bugs in the tests since we are intentionally
checking in failing tests (in this branch off the 3x branch).


=== Zope3/lib/python/Zope/App/Security/tests/testAttributePrincipalPermissionManager.py 1.1.2.1 => 1.1.2.1.2.1 ===
         
     def _make_principal(self, id=None, title=None):
-        prinregistry.definePrincipal(
+        p = prinregistry.definePrincipal(
             id or 'APrincipal',
             title or 'A Principal',
             login = id or 'APrincipal')
-        return id or 'APrincipal'
+        return p.getId()
 
     def testUnboundPrincipalPermission(self):
         manager = AttributePrincipalPermissionManager(Manageable())
         permission = permregistry.definePermission('APerm', 'title')
+        permission = permission.getId()
         principal = self._make_principal()
         self.assertEqual(manager.getPrincipalsForPermission(permission), [])
         self.assertEqual(manager.getPermissionsForPrincipal(principal), [])
@@ -48,6 +49,7 @@
     def testPrincipalPermission(self):
         manager = AttributePrincipalPermissionManager(Manageable())
         permission = permregistry.definePermission('APerm', 'title')
+        permission = permission.getId()
         principal = self._make_principal()
         # check that an allow permission is saved correctly
         manager.grantPermissionToPrincipal(permission, principal)
@@ -93,8 +95,8 @@
 
     def testManyPermissionsOnePrincipal(self):
         manager = AttributePrincipalPermissionManager(Manageable())
-        perm1 = permregistry.definePermission('Perm One', 'title')
-        perm2 = permregistry.definePermission('Perm Two', 'title')
+        perm1 = permregistry.definePermission('Perm One', 'title').getId()
+        perm2 = permregistry.definePermission('Perm Two', 'title').getId()
         prin1 = self._make_principal()
         manager.grantPermissionToPrincipal(perm1, prin1)
         manager.grantPermissionToPrincipal(perm2, prin1)