[Zope3-checkins] CVS: Zope3/src/zope/app/security/grants/tests - test_annotationprincipalpermissionmanager.py:1.1.2.2 test_annotationprincipalrolemanager.py:1.1.2.2 test_annotationrolepermissionmanager.py:1.1.2.2 test_principalpermissionmanager.py:1.1.2.2 test_principalrolemanager.py:1.1.2.2 test_rolepermissionmanager.py:1.1.2.2
Tim Peters
tim.one@comcast.net
Tue, 24 Dec 2002 21:21:48 -0500
Update of /cvs-repository/Zope3/src/zope/app/security/grants/tests
In directory cvs.zope.org:/tmp/cvs-serv19240/src/zope/app/security/grants/tests
Modified Files:
Tag: NameGeddon-branch
test_annotationprincipalpermissionmanager.py
test_annotationprincipalrolemanager.py
test_annotationrolepermissionmanager.py
test_principalpermissionmanager.py
test_principalrolemanager.py test_rolepermissionmanager.py
Log Message:
Whitespace normalization, via Python's Tools/scripts/reindent.py. The
files are fixed-points of that script now. Fixed a few cases where
code relied on significant trailing whitespace (ouch).
=== Zope3/src/zope/app/security/grants/tests/test_annotationprincipalpermissionmanager.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/grants/tests/test_annotationprincipalpermissionmanager.py:1.1.2.1 Mon Dec 23 14:32:19 2002
+++ Zope3/src/zope/app/security/grants/tests/test_annotationprincipalpermissionmanager.py Tue Dec 24 21:20:47 2002
@@ -2,7 +2,7 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
@@ -25,7 +25,7 @@
from zope.app.security.registries.principalregistry \
import principalRegistry as prinregistry
from zope.app.security.grants.annotationprincipalpermissionmanager \
- import AnnotationPrincipalPermissionManager
+ import AnnotationPrincipalPermissionManager
from zope.app.security.settings import Allow, Deny, Unset
from zope.app.tests.placelesssetup import PlacelessSetup
@@ -33,7 +33,7 @@
__implements__ = IAttributeAnnotatable
class Test(PlacelessSetup, unittest.TestCase):
-
+
def setUp(self):
PlacelessSetup.setUp(self)
getService(None,"Adapters").provideAdapter(
@@ -60,53 +60,53 @@
permission = permregistry.definePermission('APerm', 'title')
permission = permission.getId()
principal = self._make_principal()
-
+
# check that an allow permission is saved correctly
manager.grantPermissionToPrincipal(permission, principal)
self.assertEqual(manager.getPrincipalsForPermission(permission),
[(principal, Allow)])
self.assertEqual(manager.getPermissionsForPrincipal(principal),
[(permission, Allow)])
-
+
# check that the allow permission is removed.
manager.unsetPermissionForPrincipal(permission, principal)
self.assertEqual(manager.getPrincipalsForPermission(permission), [])
self.assertEqual(manager.getPermissionsForPrincipal(principal), [])
-
+
# now put a deny in there, check it's set.
manager.denyPermissionToPrincipal(permission, principal)
self.assertEqual(manager.getPrincipalsForPermission(permission),
[(principal, Deny)])
self.assertEqual(manager.getPermissionsForPrincipal(principal),
[(permission, Deny)])
-
+
# test for deny followed by allow . The latter should override.
manager.grantPermissionToPrincipal(permission, principal)
self.assertEqual(manager.getPrincipalsForPermission(permission),
[(principal, Allow)])
self.assertEqual(manager.getPermissionsForPrincipal(principal),
[(permission, Allow)])
-
+
# check that allow followed by allow is just a single allow.
manager.grantPermissionToPrincipal(permission, principal)
self.assertEqual(manager.getPrincipalsForPermission(permission),
[(principal, Allow)])
self.assertEqual(manager.getPermissionsForPrincipal(principal),
[(permission, Allow)])
-
+
# check that two unsets in a row quietly ignores the second one.
manager.unsetPermissionForPrincipal(permission, principal)
manager.unsetPermissionForPrincipal(permission, principal)
self.assertEqual(manager.getPrincipalsForPermission(permission), [])
self.assertEqual(manager.getPermissionsForPrincipal(principal), [])
-
+
# check the result of getSetting() when it's empty.
self.assertEqual(manager.getSetting(permission, principal), Unset)
-
+
# check the result of getSetting() when it's allowed.
manager.grantPermissionToPrincipal(permission, principal)
self.assertEqual(manager.getSetting(permission, principal), Allow)
-
+
# check the result of getSetting() when it's denied.
manager.denyPermissionToPrincipal(permission, principal)
self.assertEqual(manager.getSetting(permission, principal), Deny)
=== Zope3/src/zope/app/security/grants/tests/test_annotationprincipalrolemanager.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/grants/tests/test_annotationprincipalrolemanager.py:1.1.2.1 Mon Dec 23 14:32:19 2002
+++ Zope3/src/zope/app/security/grants/tests/test_annotationprincipalrolemanager.py Tue Dec 24 21:20:47 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""Test handler for PrincipalRoleManager module."""
@@ -39,7 +39,7 @@
getService(None, "Adapters").provideAdapter(
IAttributeAnnotatable, IAnnotations,
AttributeAnnotations)
-
+
def _make_principal(self, id=None, title=None):
p = pregistry.definePrincipal(
id or 'APrincipal',
=== Zope3/src/zope/app/security/grants/tests/test_annotationrolepermissionmanager.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/grants/tests/test_annotationrolepermissionmanager.py:1.1.2.1 Mon Dec 23 14:32:19 2002
+++ Zope3/src/zope/app/security/grants/tests/test_annotationrolepermissionmanager.py Tue Dec 24 21:20:47 2002
@@ -9,7 +9,7 @@
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
from zope.app.security.grants.annotationrolepermissionmanager \
import AnnotationRolePermissionManager
@@ -42,21 +42,21 @@
provideService('Roles', roleRegistry)
provideService('Permissions', permissionRegistry)
provideAdapter=getService(None,"Adapters").provideAdapter
- provideAdapter(IAttributeAnnotatable, IAnnotations,
- AttributeAnnotations)
+ provideAdapter(IAttributeAnnotatable, IAnnotations,
+ AttributeAnnotations)
read = permissionRegistry.definePermission('read', 'Read Something')
self.read = read.getId()
-
+
write = permissionRegistry.definePermission('write', 'Write Something')
self.write = write.getId()
peon = roleRegistry.defineRole('peon', 'Poor Slob')
self.peon = peon.getId()
-
+
manager = roleRegistry.defineRole('manager', 'Supreme Being')
self.manager = manager.getId()
-
+
def testNormal(self):
obj = Manageable()
mgr = AnnotationRolePermissionManager(obj)
=== Zope3/src/zope/app/security/grants/tests/test_principalpermissionmanager.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/grants/tests/test_principalpermissionmanager.py:1.1.2.1 Mon Dec 23 17:22:40 2002
+++ Zope3/src/zope/app/security/grants/tests/test_principalpermissionmanager.py Tue Dec 24 21:20:47 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""Test handler for PrincipalPermissionManager module."""
@@ -26,7 +26,7 @@
from zope.testing.cleanup import CleanUp # Base class w registry cleanup
class Test(CleanUp, unittest.TestCase):
-
+
def _make_principal(self, id=None, title=None):
p = prinregistry.definePrincipal(
id or 'APrincipal',
=== Zope3/src/zope/app/security/grants/tests/test_principalrolemanager.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/grants/tests/test_principalrolemanager.py:1.1.2.1 Mon Dec 23 17:22:40 2002
+++ Zope3/src/zope/app/security/grants/tests/test_principalrolemanager.py Tue Dec 24 21:20:47 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""Test handler for PrincipalRoleManager module."""
@@ -26,7 +26,7 @@
from zope.testing.cleanup import CleanUp # Base class w registry cleanup
class Test(CleanUp, unittest.TestCase):
-
+
def _make_principal(self, id=None, title=None):
p = pregistry.definePrincipal(
id or 'APrincipal',
=== Zope3/src/zope/app/security/grants/tests/test_rolepermissionmanager.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/grants/tests/test_rolepermissionmanager.py:1.1.2.1 Mon Dec 23 17:22:40 2002
+++ Zope3/src/zope/app/security/grants/tests/test_rolepermissionmanager.py Tue Dec 24 21:20:47 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""Test handler for RolePermissionManager module."""
@@ -27,7 +27,7 @@
from zope.testing.cleanup import CleanUp # Base class w registry cleanup
class Test(CleanUp, unittest.TestCase):
-
+
def testUnboundRolePermission(self):
permission = pregistry.definePermission('APerm', 'aPerm title').getId()
role = rregistry.defineRole('ARole', 'A Role').getId()
@@ -38,9 +38,9 @@
permission = pregistry.definePermission('APerm', 'aPerm title').getId()
role = rregistry.defineRole('ARole', 'A Role').getId()
manager.grantPermissionToRole(permission, role)
- self.assertEqual(manager.getRolesForPermission(permission),
+ self.assertEqual(manager.getRolesForPermission(permission),
[(role,Allow)])
- self.assertEqual(manager.getPermissionsForRole(role),
+ self.assertEqual(manager.getPermissionsForRole(role),
[(permission,Allow)])
def testManyPermissionsOneRole(self):