[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testPermissionRegistry.py:1.1.2.6
Barry Warsaw
barry@wooz.org
Thu, 13 Dec 2001 13:03:58 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv11497/lib/python/Zope/App/Security/tests
Modified Files:
Tag: Zope-3x-branch
testPermissionRegistry.py
Log Message:
Update tests for new PermissionRegistry interface
=== Zope3/lib/python/Zope/App/Security/tests/testPermissionRegistry.py 1.1.2.5 => 1.1.2.6 ===
# FOR A PARTICULAR PURPOSE.
-""" Test handler for 'definePermission' directive """
+"""Test handler for 'definePermission' directive"""
import unittest, sys
-from Zope.App.Security.PermissionRegistry import definePermission
-from Zope.App.Security.PermissionRegistry import definedPermission
-from Zope.App.Security.PermissionRegistry import getPermission
+from Zope.App.Security.PermissionRegistry import registry
from Zope.App.Security.IPermission import IPermission
from Interface.verify import verify
class Test(unittest.TestCase):
def tearDown(self):
- from Zope.App.Security.PermissionRegistry import _clear
- _clear()
+ registry._clear()
def testEmptyPermissions(self):
- self.assertRaises(LookupError, getPermission, 'Foo')
- self.failIf(definedPermission('Foo'))
- self.assertEqual(getPermission('Foo', None), None)
+ self.assertRaises(LookupError, registry.getPermission, 'Foo')
+ self.failIf(registry.definedPermission('Foo'))
def testPermissionIsAnIPermission(self):
- definePermission('Foo')
- permission = getPermission('Foo')
+ registry.definePermission('Foo')
+ permission = registry.getPermission('Foo')
self.assertEqual(verify(IPermission, permission), 1)
def testDefinePermission(self):
- perm = definePermission('Foo')
+ perm = registry.definePermission('Foo')
self.failUnless(verify(IPermission, perm))
- self.failUnless(definedPermission('Foo'))
- permission = getPermission('Foo')
+ self.failUnless(registry.definedPermission('Foo'))
+ permission = registry.getPermission('Foo')
self.assertEquals(permission.getTitle(), 'Foo')
def testDefinePermissionWithTitle(self):
eq = self.assertEqual
- definePermission('Foo', 'Foo-able')
- permission = getPermission('Foo')
+ registry.definePermission('Foo', 'Foo-able')
+ permission = registry.getPermission('Foo')
eq(permission.getTitle(), 'Foo-able')
eq(permission.getDescription(), '')
def testDefinePermissionWithTitleAndDescription(self):
eq = self.assertEqual
- definePermission('Foo', 'Foo-able', 'A foo-worthy permission')
- permission = getPermission('Foo')
+ registry.definePermission('Foo', 'Foo-able', 'A foo-worthy permission')
+ permission = registry.getPermission('Foo')
eq(permission.getTitle(), 'Foo-able')
eq(permission.getDescription(), 'A foo-worthy permission')