[CMF-checkins] CVS: CMF/CMFCore/tests - test_MembershipTool.py:1.2.14.1
Yvo Schubbe
schubbe@web.de
Wed, 28 May 2003 06:56:03 -0400
Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv32344/CMFCore/tests
Modified Files:
Tag: CMF-1_4-branch
test_MembershipTool.py
Log Message:
Merged yuppie-collector162-branch:
- Fixed member area Ownership and Roles. (Collector #162)
=== CMF/CMFCore/tests/test_MembershipTool.py 1.2 => 1.2.14.1 ===
--- CMF/CMFCore/tests/test_MembershipTool.py:1.2 Mon Jan 6 16:04:41 2003
+++ CMF/CMFCore/tests/test_MembershipTool.py Wed May 28 06:55:33 2003
@@ -2,14 +2,34 @@
import Zope
try:
+ Zope.startup()
+except AttributeError:
+ # for Zope versions before 2.6.1
+ pass
+try:
from Interface.Verify import verifyClass
except ImportError:
# for Zope versions before 2.6.0
from Interface import verify_class_implementation as verifyClass
+from Products.CMFCore.PortalFolder import PortalFolder
+from Products.CMFCore.tests.base.dummy import DummyFolder as DummyFolderBase
+from Products.CMFCore.tests.base.dummy import DummyTool
+from Products.CMFCore.tests.base.dummy import DummyUserFolder
+from Products.CMFCore.tests.base.testcase import SecurityTest
+
from Products.CMFCore.MembershipTool import MembershipTool
+class DummyFolder(DummyFolderBase):
+ def _getProductRegistryData(self, name):
+ return ()
+ def getPhysicalRoot(self):
+ return self
+ def unrestrictedTraverse(self, path, default=None, restricted=0):
+ return self.acl_users
+
+
class MembershipToolTests(TestCase):
def test_interface(self):
@@ -22,9 +42,34 @@
verifyClass(IActionProvider, MembershipTool)
+class MembershipToolSecurityTests(SecurityTest):
+
+ def setUp(self):
+ SecurityTest.setUp(self)
+ self.site = DummyFolder()
+ self.site.id = 'testSite'
+ self.mtool = MembershipTool().__of__(self.site)
+
+ def test_createMemberarea(self):
+ mtool = self.mtool
+ self.site._setObject( 'Members', PortalFolder('Members') )
+ self.site._setObject( 'acl_users', DummyUserFolder() )
+ self.site._setObject( 'portal_workflow', DummyTool() )
+ mtool.createMemberarea('user_foo')
+
+ f = self.site.Members.user_foo
+ ownership = self.site.acl_users.user_foo
+ localroles = ( ( 'user_foo', ('Owner',) ), )
+ self.assertEqual( f.getOwner(), ownership )
+ self.assertEqual( f.get_local_roles(), localroles,
+ 'CMF Collector issue #162 (LocalRoles broken): %s'
+ % str( f.get_local_roles() ) )
+
+
def test_suite():
return TestSuite((
makeSuite( MembershipToolTests ),
+ makeSuite( MembershipToolSecurityTests )
))
if __name__ == '__main__':