[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testPrincipalPermissionView.py:1.1.2.9.2.1 testPrincipalRoleView.py:1.1.2.8.2.1 testRolePermissionView.py:1.1.2.7.2.1
Jim Fulton
jim@zope.com
Wed, 29 May 2002 11:10:17 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv12181/lib/python/Zope/App/Security/tests
Modified Files:
Tag: Zope3InWonderland-branch
testPrincipalPermissionView.py testPrincipalRoleView.py
testRolePermissionView.py
Log Message:
- Added permission_id attribute to adapter and utility directives.
- Got rid of old getView, getResource, and getDefaultViewName.
Renamed getRequestView to getView (and so on).
Changed view interface to use context, rather than getContext.
Introduced notion of presentation types (e.g. IBrowserPresentation,
which is cleaner than IBrowserPublisher).
- Began converting to get/queryFoo, which is much nicer.
- Many formatting fixups.
=== Zope3/lib/python/Zope/App/Security/tests/testPrincipalPermissionView.py 1.1.2.9 => 1.1.2.9.2.1 ===
from Zope.App.Security.PrincipalPermissionView \
import PrincipalPermissionView
- return PrincipalPermissionView(DummyContext())
+ return PrincipalPermissionView(DummyContext(), None)
def testGrantPermissions(self):
view = self._makeOne()
=== Zope3/lib/python/Zope/App/Security/tests/testPrincipalRoleView.py 1.1.2.8 => 1.1.2.8.2.1 ===
__implements__ = IRoleService
- def __init__( self, roles ):
+ def __init__(self, roles):
self._roles = roles
- def getRoles( self ):
+ def getRoles(self):
return self._roles
class DummyObject:
- def __init__( self, id, title ):
+ def __init__(self, id, title):
self._id = id
self._title = title
- def getId( self ):
+ def getId(self):
return self._id
- def getTitle( self ):
+ def getTitle(self):
return self._title
class DummyAuthenticationService:
__implements__ = IAuthenticationService
- def __init__( self, principals ):
+ def __init__(self, principals):
self._principals = principals
- def getPrincipals( self ):
+ def getPrincipals(self):
return self._principals
-class Test(PlacefulSetup, unittest.TestCase ):
+class Test(PlacefulSetup, unittest.TestCase):
def setUp(self):
PlacefulSetup.setUp(self)
self._roles = []
- self._roles.append( DummyObject( 'qux', 'Qux' ) )
- self._roles.append( DummyObject( 'baz', 'Baz' ) )
+ self._roles.append(DummyObject('qux', 'Qux'))
+ self._roles.append(DummyObject('baz', 'Baz'))
defineService=getServiceManager(None).defineService
provideService=getServiceManager(None).provideService
- defineService( 'RoleService', IRoleService )
- provideService( 'RoleService'
- , DummyRoleService( roles = self._roles ) )
+ defineService('RoleService', IRoleService)
+ provideService('RoleService'
+ , DummyRoleService(roles = self._roles))
- defineService( 'AuthenticationService', IAuthenticationService )
+ defineService('AuthenticationService', IAuthenticationService)
self._principals = []
- self._principals.append( DummyObject( 'foo', 'Foo' ) )
- self._principals.append( DummyObject( 'bar', 'Bar' ) )
+ self._principals.append(DummyObject('foo', 'Foo'))
+ self._principals.append(DummyObject('bar', 'Bar'))
- provideService( 'AuthenticationService',
- DummyAuthenticationService( principals = self._principals ) )
+ provideService('AuthenticationService',
+ DummyAuthenticationService(principals = self._principals))
- def _makeOne( self ):
+ def _makeOne(self):
from Zope.App.Security.PrincipalRoleView import PrincipalRoleView
- return PrincipalRoleView( DummyManager() )
+ return PrincipalRoleView(DummyManager(), None)
def testRoles(self):
view = self._makeOne()
roles = list(view.getAllRoles())
- self.assertEqual( len( roles ), 2 )
+ self.assertEqual(len(roles), 2)
- ids = map( lambda x: x.getId(), self._roles )
- titles = map( lambda x: x.getTitle(), self._roles )
+ ids = map(lambda x: x.getId(), self._roles)
+ titles = map(lambda x: x.getTitle(), self._roles)
for role in roles:
- self.failUnless( role.getId() in ids )
- self.failUnless( role.getTitle() in titles )
+ self.failUnless(role.getId() in ids)
+ self.failUnless(role.getTitle() in titles)
def testPrincipals(self):
view = self._makeOne()
principals = list(view.getAllPrincipals())
- self.assertEqual( len( principals ), 2 )
+ self.assertEqual(len(principals), 2)
- ids = map( lambda x: x.getId(), self._principals )
- titles = map( lambda x: x.getTitle(), self._principals )
+ ids = map(lambda x: x.getId(), self._principals)
+ titles = map(lambda x: x.getTitle(), self._principals)
for principal in principals:
- self.failUnless( principal.getId() in ids )
- self.failUnless( principal.getTitle() in titles )
+ self.failUnless(principal.getId() in ids)
+ self.failUnless(principal.getTitle() in titles)
def testPrincipalRoleGrid(self):
view = self._makeOne()
@@ -125,7 +125,7 @@
p_ids = [p.getId() for p in view.getAllPrincipals()]
r_ids = [r.getId() for r in view.getAllRoles()]
- self.failUnless( grid.listAvailableValues())
+ self.failUnless(grid.listAvailableValues())
for id in [p.getId() for p in grid.principals()]:
self.failUnless(id in p_ids)
=== Zope3/lib/python/Zope/App/Security/tests/testRolePermissionView.py 1.1.2.7 => 1.1.2.7.2.1 ===
provideService('PermissionService', PermissionService(
read='Read', write='Write'))
- self.view = RolePermissionView(RolePermissionManager())
+ self.view = RolePermissionView(RolePermissionManager(), None)
def testRoles(self):
roles = list(self.view.roles())