Commit 443514cd authored by Tres Seaver's avatar Tres Seaver

- Clean up spurious import dependencies.

parent 3f0db85b
...@@ -10,22 +10,34 @@ ...@@ -10,22 +10,34 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
""" """ """ Unit tests for ClassSecurityInfo.
"""
import os, sys, unittest, ZODB, Globals import unittest
from AccessControl.SecurityInfo import ClassSecurityInfo
from OFS.Folder import Folder
class ClassSecurityInfoTests(unittest.TestCase): class ClassSecurityInfoTests(unittest.TestCase):
def testSetPermissionDefault(self): def _getTargetClass(self):
from AccessControl.SecurityInfo import ClassSecurityInfo
return ClassSecurityInfo
def test_SetPermissionDefault(self):
# Test setting default roles for permissions. # Test setting default roles for permissions.
import Globals # XXX: avoiding import cycle
from App.class_init import default__class_init__
from ExtensionClass import Base
ClassSecurityInfo = self._getTargetClass()
# Setup a test class with default role -> permission decls. # Setup a test class with default role -> permission decls.
class Test(Folder): class Test(Base):
"""Test class""" """Test class
"""
__ac_roles__ = ('Role A', 'Role B', 'Role C') __ac_roles__ = ('Role A', 'Role B', 'Role C')
meta_type = "Test" meta_type = "Test"
...@@ -43,7 +55,7 @@ class ClassSecurityInfoTests(unittest.TestCase): ...@@ -43,7 +55,7 @@ class ClassSecurityInfoTests(unittest.TestCase):
pass pass
# Do class initialization. # Do class initialization.
Globals.InitializeClass(Test) default__class_init__(Test)
# Now check the resulting class to see if the mapping was made # Now check the resulting class to see if the mapping was made
# correctly. Note that this uses carnal knowledge of the internal # correctly. Note that this uses carnal knowledge of the internal
...@@ -51,6 +63,7 @@ class ClassSecurityInfoTests(unittest.TestCase): ...@@ -51,6 +63,7 @@ class ClassSecurityInfoTests(unittest.TestCase):
object = Test() object = Test()
imPermissionRole = object.foo__roles__ imPermissionRole = object.foo__roles__
self.failUnless(len(imPermissionRole) == 4) self.failUnless(len(imPermissionRole) == 4)
for item in ('Manager', 'Role A', 'Role B', 'Role C'): for item in ('Manager', 'Role A', 'Role B', 'Role C'):
self.failUnless(item in imPermissionRole) self.failUnless(item in imPermissionRole)
...@@ -60,8 +73,5 @@ def test_suite(): ...@@ -60,8 +73,5 @@ def test_suite():
suite.addTest(unittest.makeSuite(ClassSecurityInfoTests)) suite.addTest(unittest.makeSuite(ClassSecurityInfoTests))
return suite return suite
def main():
unittest.TextTestRunner().run(test_suite())
if __name__ == '__main__': if __name__ == '__main__':
main() unittest.main(defaultTest='test_suite')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment