[Zope3-checkins] CVS: Zope3/src/zope/app/browser/security/grants/tests - permissionservice.py:1.1.2.3 rolepermissionmanager.py:1.1.2.2 roleservice.py:1.1.2.3 test_principalpermissionview.py:1.1.2.2 test_principalroleview.py:1.1.2.2
Tim Peters
tim.one@comcast.net
Tue, 24 Dec 2002 21:21:47 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/security/grants/tests
In directory cvs.zope.org:/tmp/cvs-serv19240/src/zope/app/browser/security/grants/tests
Modified Files:
Tag: NameGeddon-branch
permissionservice.py rolepermissionmanager.py roleservice.py
test_principalpermissionview.py test_principalroleview.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/browser/security/grants/tests/permissionservice.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/browser/security/grants/tests/permissionservice.py:1.1.2.2 Tue Dec 24 07:50:52 2002
+++ Zope3/src/zope/app/browser/security/grants/tests/permissionservice.py Tue Dec 24 21:20:15 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.
-#
+#
##############################################################################
"""PermissionService implementation for testing
@@ -34,7 +34,7 @@
def __init__(self, **kw):
self._permissions = r = {}
- for id, title in kw.items(): r[id]=Permission(id, title)
+ for id, title in kw.items(): r[id]=Permission(id, title)
def getPermission(self, rid):
'''See interface IPermissionService'''
=== Zope3/src/zope/app/browser/security/grants/tests/rolepermissionmanager.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/browser/security/grants/tests/rolepermissionmanager.py:1.1.2.1 Mon Dec 23 14:31:11 2002
+++ Zope3/src/zope/app/browser/security/grants/tests/rolepermissionmanager.py Tue Dec 24 21:20:15 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 IRolePermissionManager class that has no context.
@@ -85,5 +85,3 @@
"""Get the role permission map stored in the context, optionally
creating one if necessary"""
return self._rp
-
-
=== Zope3/src/zope/app/browser/security/grants/tests/roleservice.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/browser/security/grants/tests/roleservice.py:1.1.2.2 Tue Dec 24 07:50:52 2002
+++ Zope3/src/zope/app/browser/security/grants/tests/roleservice.py Tue Dec 24 21:20:15 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.
-#
+#
##############################################################################
"""RoleService implementation for testing
@@ -30,11 +30,11 @@
class RoleService:
- __implements__ = IRoleService
+ __implements__ = IRoleService
def __init__(self, **kw):
self._roles = r = {}
- for id, title in kw.items(): r[id]=Role(id, title)
+ for id, title in kw.items(): r[id]=Role(id, title)
def getRole(self, rid):
return self._roles.get(rid)
=== Zope3/src/zope/app/browser/security/grants/tests/test_principalpermissionview.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/browser/security/grants/tests/test_principalpermissionview.py:1.1.2.1 Mon Dec 23 14:31:11 2002
+++ Zope3/src/zope/app/browser/security/grants/tests/test_principalpermissionview.py Tue Dec 24 21:20:15 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
@@ -44,7 +44,7 @@
perms = {}
for perm_obj in perm_objs:
perms[perm_obj.getId()] = perm_obj
-
+
self.perms = perms
def getPermission(self,pr_id):
@@ -52,11 +52,11 @@
def getPermissions(self):
return self.perms.keys()
-
+
class DummyAuthenticationService:
__implements__ = IAuthenticationService
-
+
def __init__(self, principals):
pr = {}
for principal in principals:
@@ -65,26 +65,26 @@
def getPrincipal(self, principal_id):
return self.principals[principal_id]
-
+
class DummyAdapter:
__implements__ = IPrincipalPermissionManager, IPrincipalPermissionMap
-
+
def __init__(self, context):
self._context = context
if not hasattr(self._context,'principals'):
self._context.principals = {}
-
+
def grantPermissionToPrincipal(self, permission, principal):
if not (principal in self._context.principals):
self._context.principals[principal]={}
-
+
self._context.principals[principal][permission]=Allow
def denyPermissionToPrincipal(self, permission, principal):
if not (principal in self._context.principals):
self._context.principals[principal]={}
-
+
self._context.principals[principal][permission]=Deny
def unsetPermissionForPrincipal(self, permission, principal):
@@ -98,7 +98,7 @@
def getSetting(self, permission, principal):
try:
setting = self._context.principals[principal][permission]
-
+
except KeyError:
setting = Unset
@@ -110,13 +110,13 @@
if permissions in permissions:
ret.append((principal, permissions[permission]))
return ret
-
+
def getPermissionsForPrincipal(self, principal):
try:
return self._context.principals[principal].items()
except KeyError:
return []
-
+
class DummyObject:
def __init__(self, id, title):
self._id = id
@@ -170,7 +170,7 @@
self._principals[0].getId(), 'Allow')
denied_perms = view.getPermissionsForPrincipal(
self._principals[0].getId(), 'Deny')
-
+
self.assertEqual(len(allowed_perms), 0, 'List not empty')
self.assertEqual(len(denied_perms), 0, 'List not empty')
view.grantPermissions(self._principals[0].getId(),
@@ -215,7 +215,7 @@
self._principals[0].getId(), 'Allow')
denied_perms = view.getPermissionsForPrincipal(
self._principals[0].getId(), 'Deny')
-
+
self.assertEqual(len(allowed_perms), 0, 'List not empty')
self.assertEqual(len(denied_perms), 0, 'List not empty')
view.denyPermissions(self._principals[0].getId(),
@@ -260,7 +260,7 @@
self._principals[0].getId(), 'Allow')
denied_perms = view.getPermissionsForPrincipal(
self._principals[0].getId(), 'Deny')
-
+
self.assertEqual(len(allowed_perms), 0, 'List not empty')
self.assertEqual(len(denied_perms), 0, 'List not empty')
@@ -287,7 +287,7 @@
self.assertEqual(view.getPermissionsForPrincipal(
self._principals[0].getId(),'Allow'),
[])
-
+
view.grantPermissions(self._principals[0].getId(),
[self._permissions[1].getId()])
self.assertEqual(view.getPermissionsForPrincipal(
@@ -349,7 +349,7 @@
unset_perms = view.getUnsetPermissionsForPrincipal(
self._principals[0].getId())
self.assertEqual(len(unset_perms), 2, 'Not all permissions unset')
-
+
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
=== Zope3/src/zope/app/browser/security/grants/tests/test_principalroleview.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/browser/security/grants/tests/test_principalroleview.py:1.1.2.1 Mon Dec 23 14:31:11 2002
+++ Zope3/src/zope/app/browser/security/grants/tests/test_principalroleview.py Tue Dec 24 21:20:15 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.
-#
+#
##############################################################################
"""