[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testPrincipalRoleView.py:1.1.2.2
alan runyan
runyaga@runyaga.com
Fri, 8 Feb 2002 18:18:14 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv27250/tests
Modified Files:
Tag: Zope-3x-branch
testPrincipalRoleView.py
Log Message:
principal role association testing code.
=== Zope3/lib/python/Zope/App/Security/tests/testPrincipalRoleView.py 1.1.2.1 => 1.1.2.2 ===
from Zope.App.Security.IPrincipalRoleManager import IPrincipalRoleManager
+from Zope.App.Security.IPrincipalRoleMap import IPrincipalRoleMap
class DummyManager:
__implements__ = IPrincipalRoleManager
+ def getSetting(self, role, principal):
+ return '%r:%r' % (role, principal)
+
class DummyRoleService:
__implements__ = IRoleService
@@ -108,8 +112,31 @@
self.failUnless( principal.getId() in ids )
self.failUnless( principal.getTitle() in titles )
+ def testPrincipalRoleGrid(self):
+ view = self._makeOne()
+ grid = view.createGrid()
+
+ p_ids = view.getAllPrincipals()
+ r_ids = view.getAllRoles()
+
+ self.failUnless( grid.listAvailableValues())
+ for id in [p.getId() for p in grid.principals()]:
+ self.failUnless( id not in p_ids)
+
+ for id in [r.getId() for r in grid.roles()]:
+ self.failUnless( id not in r_ids)
+
+ map = DummyManager()
+
+ grid_entries = [(r, p, map.getSetting(r, p))
+ for r in grid.roles()
+ for p in grid.principals()]
+
+ for r, p, setting in grid_entries:
+ self.assertEquals(setting, grid.getValue(r, p))
+
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)