[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testPrincipalRegistry.py:1.1.2.4
Guido van Rossum
guido@python.org
Thu, 13 Dec 2001 12:50:46 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv6841/tests
Modified Files:
Tag: Zope-3x-branch
testPrincipalRegistry.py
Log Message:
Add defaultPrincipal() method and associated machinery.
=== Zope3/lib/python/Zope/App/Security/tests/testPrincipalRegistry.py 1.1.2.3 => 1.1.2.4 ===
self.assertEquals(pid, None)
+ def testDefaultPrincipal(self):
+ self.assertEquals(self.reg.defaultPrincipal(), None)
+ self.assertRaises(DuplicateId, self.reg.defineDefaultPrincipal,
+ "1", "tim")
+ self.reg.defineDefaultPrincipal("everybody", "Default Principal")
+ self.assertEquals(self.reg.defaultPrincipal(), "everybody")
+ self.reg.defineDefaultPrincipal("anybody", "Default Principal",
+ "This is the default headmaster")
+ self.assertEquals(self.reg.defaultPrincipal(), "anybody")
+ self.assertRaises(NotFoundError, self.reg.getPrincipal, "everybody")
+ p = self.reg.getPrincipal("anybody")
+ self.assertEquals(p.getId(), "anybody")
+ self.assertEquals(p.getTitle(), "Default Principal")
+ self.assertRaises(DuplicateId, self.reg.definePrincipal,
+ "anybody", "title")
+
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)