[CMF-checkins] CVS: CMF/CMFDefault/tests - test_MembershipTool.py:1.7 test_join.py:1.9

Yvo Schubbe schubbe@web.de
Mon, 2 Jun 2003 12:18:51 -0400


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

Modified Files:
	test_MembershipTool.py test_join.py 
Log Message:
Merged yuppie-createMemberarea-branch:
- Made logged_in page instead of wrapUser call 'createMemberarea'.
- Added a customization hook to CMFDefault 'createMemberarea'.

=== CMF/CMFDefault/tests/test_MembershipTool.py 1.6 => 1.7 ===
--- CMF/CMFDefault/tests/test_MembershipTool.py:1.6	Wed May 28 06:57:42 2003
+++ CMF/CMFDefault/tests/test_MembershipTool.py	Mon Jun  2 12:18:50 2003
@@ -11,6 +11,7 @@
 except ImportError:
     # for Zope versions before 2.6.0
     from Interface import verify_class_implementation as verifyClass
+from AccessControl.SecurityManagement import newSecurityManager
 
 from Products.CMFCore.PortalFolder import PortalFolder
 from Products.CMFCore.tests.base.dummy import DummyFolder as DummyFolderBase
@@ -39,18 +40,6 @@
         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', DummyTool() )
-        self.site.user_bar = 'test attribute'
-        mtool.createMemberarea('user_foo')
-        self.failUnless( hasattr(self.site.Members.aq_self, 'user_foo') )
-        mtool.createMemberarea('user_bar')
-        self.failUnless( hasattr(self.site.Members.aq_self, 'user_bar'),
-                         'CMF Collector issue #102 (acquisition bug)' )
-
     def test_MembersFolder_methods(self):
         mtool = self.mtool
         self.assertEqual( mtool.getMembersFolder(), None )
@@ -83,14 +72,29 @@
 
     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() )
+        members = self.site._setObject( 'Members', PortalFolder('Members') )
+        acl_users = self.site._setObject( 'acl_users', DummyUserFolder() )
+        wtool = self.site._setObject( 'portal_workflow', DummyTool() )
+
+        # permission
+        mtool.createMemberarea('user_foo')
+        self.failIf( hasattr(members.aq_self, 'user_foo') )
+        newSecurityManager(None, acl_users.user_bar)
+        mtool.createMemberarea('user_foo')
+        self.failIf( hasattr(members.aq_self, 'user_foo') )
+        newSecurityManager(None, acl_users.user_foo)
+        mtool.setMemberareaCreationFlag()
+        mtool.createMemberarea('user_foo')
+        self.failIf( hasattr(members.aq_self, 'user_foo') )
+        mtool.setMemberareaCreationFlag()
         mtool.createMemberarea('user_foo')
+        self.failUnless( hasattr(members.aq_self, 'user_foo') )
 
-        f = self.site.Members.user_foo
-        ownership = self.site.acl_users.user_foo
+        # default content
+        f = members.user_foo
+        ownership = acl_users.user_foo
         localroles = ( ( 'user_foo', ('Owner',) ), )
+        self.assertEqual( f.Title(), "user_foo's Home" )
         self.assertEqual( f.getOwner(), ownership )
         self.assertEqual( f.get_local_roles(), localroles,
                           'CMF Collector issue #162 (LocalRoles broken): %s'
@@ -101,6 +105,14 @@
         self.assertEqual( f.index_html.get_local_roles(), localroles,
                           'CMF Collector issue #162 (LocalRoles broken): %s'
                           % str( f.index_html.get_local_roles() ) )
+        self.assertEqual( wtool.test_notified, f.index_html )
+
+        # acquisition
+        self.site.user_bar = 'test attribute'
+        newSecurityManager(None, acl_users.user_bar)
+        mtool.createMemberarea('user_bar')
+        self.failUnless( hasattr(members.aq_self, 'user_bar'),
+                         'CMF Collector issue #102 (acquisition bug)' )
 
 
 def test_suite():


=== CMF/CMFDefault/tests/test_join.py 1.8 => 1.9 ===
--- CMF/CMFDefault/tests/test_join.py:1.8	Tue Jul 23 14:38:36 2002
+++ CMF/CMFDefault/tests/test_join.py	Mon Jun  2 12:18:50 2003
@@ -1,15 +1,19 @@
-import Zope
 from unittest import TestSuite, makeSuite, main
 
-from Products.CMFCore.tests.base.testcase import \
-     TransactionalTest
+import Zope
+try:
+    Zope.startup()
+except AttributeError:
+    # for Zope versions before 2.6.1
+    pass
+
+from Products.CMFCore.tests.base.testcase import TransactionalTest
 
 class MembershipTests( TransactionalTest ):
 
     def test_join( self ):
         self.root.manage_addProduct[ 'CMFDefault' ].manage_addCMFSite( 'site' )
         site = self.root.site
-        site.portal_membership.memberareaCreationFlag = 0
         member_id = 'test_user'
         site.portal_registration.addMember( member_id
                                           , 'zzyyzz'
@@ -19,17 +23,6 @@
                                           )
         u = site.acl_users.getUser(member_id)
         self.failUnless(u)
-        self.assertRaises(AttributeError,
-                          getattr, site.Members, member_id)
-        # test that wrapUser correctly creates member area
-        site.portal_membership.setMemberareaCreationFlag()
-        site.portal_membership.wrapUser(u)
-        memberfolder = getattr(site.Members, member_id)
-        homepage = memberfolder.index_html
-        self.assertEqual( memberfolder.Title(), "test_user's Home" )
-        tool = site.portal_workflow
-        self.assertEqual( tool.getInfoFor( homepage, 'review_state' )
-                        , "private" )
 
     def test_join_without_email( self ):
         self.root.manage_addProduct[ 'CMFDefault' ].manage_addCMFSite( 'site' )