[CMF-checkins] CVS: CMF/CMFDefault/tests - test_MembershipTool.py:1.3.14.1

Yvo Schubbe schubbe@web.de
Fri, 14 Mar 2003 13:23:37 -0500


Update of /cvs-repository/CMF/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv7676/CMFDefault/tests

Modified Files:
      Tag: yuppie-collector102-branch
	test_MembershipTool.py 
Log Message:
- fixed aqusition bug (Collector #102)

=== CMF/CMFDefault/tests/test_MembershipTool.py 1.3 => 1.3.14.1 ===
--- CMF/CMFDefault/tests/test_MembershipTool.py:1.3	Fri Feb 21 06:39:29 2003
+++ CMF/CMFDefault/tests/test_MembershipTool.py	Fri Mar 14 13:23:37 2003
@@ -7,22 +7,54 @@
     # for Zope versions before 2.6.0
     from Interface import verify_class_implementation as verifyClass
 
-from Products.CMFCore.tests.base.dummy import DummyFolder
+from Products.CMFCore.tests.base.dummy import DummyFolder as DummyFolderBase
+from Products.CMFCore.tests.base.dummy import DummyObject
 
 from Products.CMFDefault.MembershipTool import MembershipTool
 
 
+class DummyFolder(DummyFolderBase):
+    def manage_addPortalFolder(self, id, title=''):
+        self._setObject( id, DummyFolder() )
+    def objectIds(self):
+        return self._objects.keys()
+    def changeOwnership(self, user):
+        pass
+    def manage_setLocalRoles(self, userid, roles):
+        pass
+
+class DummyUserFolder(DummyFolderBase):
+    def getUsers(self):
+        pass
+    def getUser(self, name):
+        return DummyObject()
+
+class DummyWorkflowTool:
+    def notifyCreated(self, ob):
+        pass
+
+
 class MembershipToolTests(TestCase):
 
     def setUp(self):
         self.site = DummyFolder()
+        self.mtool = MembershipTool().__of__(self.site)
+
+    def test_createMemberarea(self):
+        mtool = self.mtool
+        self.site._setObject( 'Members', DummyFolder() )
+        self.site._setObject( 'acl_users', DummyUserFolder() )
+        self.site._setObject( 'portal_workflow', DummyWorkflowTool() )
+        self.site.bar = 'test attribute'
+        mtool.createMemberarea('foo')
+        self.failUnless( hasattr(self.site.Members.aq_self, 'foo') )
+        mtool.createMemberarea('bar')
+        self.failUnless( hasattr(self.site.Members.aq_self, 'bar'),
+                         'CMF Collector issue #102'  )
 
-    def _makeOne(self, *args, **kw):
-        mtool = apply(MembershipTool, args, kw)
-        return mtool.__of__(self.site)
 
     def test_MembersFolder_methods(self):
-        mtool = self._makeOne()
+        mtool = self.mtool
         self.assertEqual( mtool.getMembersFolder(), None )
         self.site._setObject( 'Members', DummyFolder() )
         self.assertEqual( mtool.getMembersFolder(), self.site.Members )