summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTres Seaver <tseaver@palladion.com>2013-02-12 15:05:26 -0500
committerTres Seaver <tseaver@palladion.com>2013-02-12 15:05:26 -0500
commit7ae6bd7ec050159ea1bce8e8f1cac9244d390a2c (patch)
tree30698b3822d9a91b19e59ff180e516dcaf138131 /src
parent3457ca6b64719d1636b0eae311c4b41e3b252ad7 (diff)
downloadzope-security-7ae6bd7ec050159ea1bce8e8f1cac9244d390a2c.tar.gz
Coverage for z.s.permission.checkPermission.
Diffstat (limited to 'src')
-rw-r--r--src/zope/security/tests/test_permission.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/zope/security/tests/test_permission.py b/src/zope/security/tests/test_permission.py
index 1134a10..cd65182 100644
--- a/src/zope/security/tests/test_permission.py
+++ b/src/zope/security/tests/test_permission.py
@@ -55,7 +55,37 @@ class PermissionTests(unittest.TestCase):
self.assertEqual(permission.description, 'DESCRIPTION')
+class Test_checkPermission(unittest.TestCase):
+
+ def setUp(self):
+ from zope.component.testing import setUp
+ setUp()
+
+ def tearDown(self):
+ from zope.component.testing import tearDown
+ tearDown()
+
+ def _callFUT(self, context, permission_id):
+ from zope.security.permission import checkPermission
+ return checkPermission(context, permission_id)
+
+ def test_w_CheckerPublic(self):
+ from zope.security.checker import CheckerPublic
+ self._callFUT(None, CheckerPublic) # no raise
+
+ def test_miss(self):
+ self.assertRaises(ValueError, self._callFUT, None, 'nonesuch')
+
+ def test_hit(self):
+ from zope.component import provideUtility
+ from zope.security.interfaces import IPermission
+ permission = object()
+ provideUtility(permission, IPermission, 'testing')
+ self._callFUT(None, 'testing') # no raise
+
+
def test_suite():
return unittest.TestSuite([
unittest.makeSuite(PermissionTests),
+ unittest.makeSuite(Test_checkPermission),
])