[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - RolePermissionManager.py:1.1.2.2 testRolePermissionView.py:1.1.2.3
Casey Duncan
casey_duncan@yahoo.com
Fri, 1 Feb 2002 12:34:04 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv31380/tests
Modified Files:
Tag: Zope-3x-branch
RolePermissionManager.py testRolePermissionView.py
Log Message:
Added RolePermission Managment form
Added Unittests
=== Zope3/lib/python/Zope/App/Security/tests/RolePermissionManager.py 1.1.2.1 => 1.1.2.2 ===
permissions.remove(permission)
if not permissions:
- del self._rp[role]
+ # XXX: this del removed by Steve and Casey
+ # in order to get the PermissionsForRole
+ # view unit tests to work correctly.
+ #
+ # Why is this del here?
+ #
+ # It doesn't seem to break anything to remove
+ # it, like this!
+ #del self._rp[role]
+ pass
+
def grantPermissionToRole(self, permission, role):
'''See interface IRolePermissionManager'''
=== Zope3/lib/python/Zope/App/Security/tests/testRolePermissionView.py 1.1.2.2 => 1.1.2.3 ===
permissions[ip].getId() == 'read'
)
+
+ self.view.update_permission(REQUEST=None,
+ permission_id='write',
+ roles=['member'],
+ testing=1)
+ permission = self.view.permissionForID('write')
+ self.assertEquals(
+ [r['id']
+ for r in permission.rolesInfo()
+ if r['checked']],
+ ['member'])
+
+ self.view.update_permission(REQUEST=None,
+ permission_id='write',
+ # roles=[], roles attr omitted
+ testing=1)
+
+ permission = self.view.permissionForID('write')
+ self.assertEquals(
+ [r['id']
+ for r in permission.rolesInfo()
+ if r['checked']],
+ [])
+
+
+ self.view.update_permission(REQUEST=None,
+ permission_id='write',
+ roles=['manager','member'],
+ testing=1)
+
+ permission = self.view.permissionForID('write')
+ result = [r['id']
+ for r in permission.rolesInfo()
+ if r['checked']]
+ what_result_should_be = ['manager','member']
+ result.sort()
+ what_result_should_be.sort()
+ self.assertEquals(
+ result,
+ what_result_should_be
+ )
+
+ self.view.update_role(REQUEST=None,
+ role_id='member',
+ permissions=['write','read'],
+ testing=1)
+
+ role = self.view.roleForID('member')
+ result = [r['id']
+ for r in role.permissionsInfo()
+ if r['checked']]
+ what_result_should_be = ['write','read']
+ result.sort()
+ what_result_should_be.sort()
+ self.assertEquals(
+ result,
+ what_result_should_be
+ )
+
+ self.view.update_role(REQUEST=None,
+ role_id='member',
+ # omitted attribute permissions,
+ testing=1)
+
+ role = self.view.roleForID('member')
+ result = [r['id']
+ for r in role.permissionsInfo()
+ if r['checked']]
+ what_result_should_be = []
+ result.sort()
+ what_result_should_be.sort()
+ self.assertEquals(
+ result,
+ what_result_should_be
+ )