summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/zope/security/tests/test_permission.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/zope/security/tests/test_permission.py b/src/zope/security/tests/test_permission.py
index 9807fab..3ed622f 100644
--- a/src/zope/security/tests/test_permission.py
+++ b/src/zope/security/tests/test_permission.py
@@ -120,9 +120,52 @@ class Test_allPermissions(unittest.TestCase):
self.assertEqual(list(self._callFUT()), ['testing'])
+class Test_PermissionsVocabulary(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):
+ from zope.security.permission import PermissionsVocabulary
+ return PermissionsVocabulary()
+
+ def test_empty(self):
+ from zope.schema.vocabulary import SimpleVocabulary
+ vocabulary = self._callFUT()
+ self.assertTrue(isinstance(vocabulary, SimpleVocabulary))
+ self.assertEqual(list(vocabulary), [])
+
+ def test_w_registration(self):
+ self.assertEqual(list(self._callFUT()), [])
+ from zope.component import provideUtility
+ from zope.security.interfaces import IPermission
+ permission = object()
+ provideUtility(permission, IPermission, 'testing')
+ vocabulary = self._callFUT()
+ self.assertEqual([x.token for x in vocabulary], ['testing'])
+
+ def test_includes_zope_Public(self):
+ self.assertEqual(list(self._callFUT()), [])
+ from zope.component import provideUtility
+ from zope.security.checker import CheckerPublic
+ from zope.security.interfaces import IPermission
+ permission = object()
+ provideUtility(permission, IPermission, 'testing')
+ provideUtility(CheckerPublic, IPermission, 'zope.Public')
+ vocabulary = self._callFUT()
+ self.assertEqual(sorted([x.token for x in vocabulary]),
+ ['testing', 'zope.Public'])
+
+
def test_suite():
return unittest.TestSuite([
unittest.makeSuite(PermissionTests),
unittest.makeSuite(Test_checkPermission),
unittest.makeSuite(Test_allPermissions),
+ unittest.makeSuite(Test_PermissionsVocabulary),
])