[CMF-checkins] SVN: CMF/trunk/C - Refactored and extended
CMFDefault.tests.test_join so it can be easily
Jens Vagelpohl
jens at dataflake.org
Sat Sep 17 08:05:05 EDT 2005
Log message for revision 38502:
- Refactored and extended CMFDefault.tests.test_join so it can be easily
subclassed and reused for alternative membership implementations. All
that is needed is to ovverride _createPortal to return a portal with
the desired non-default membership-related tools installed.
Changed:
U CMF/trunk/CHANGES.txt
U CMF/trunk/CMFDefault/tests/test_join.py
-=-
Modified: CMF/trunk/CHANGES.txt
===================================================================
--- CMF/trunk/CHANGES.txt 2005-09-17 10:20:09 UTC (rev 38501)
+++ CMF/trunk/CHANGES.txt 2005-09-17 12:05:00 UTC (rev 38502)
@@ -76,6 +76,11 @@
Others
+ - Refactored and extended CMFDefault.tests.test_join so it can be easily
+ subclassed and reused for alternative membership implementations. All
+ that is needed is to ovverride _createPortal to return a portal with
+ the desired non-default membership-related tools installed.
+
- Remove all "old-style" actions from tools that still carried them
(CMFDefault.MembershipTool, CMFDefault.PropertiesTool,
CMFDefault.RegistrationTool, CMFDefault.SyndicationTool,
Modified: CMF/trunk/CMFDefault/tests/test_join.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_join.py 2005-09-17 10:20:09 UTC (rev 38501)
+++ CMF/trunk/CMFDefault/tests/test_join.py 2005-09-17 12:05:00 UTC (rev 38502)
@@ -25,11 +25,17 @@
class MembershipTests( TransactionalTest ):
- def test_join( self ):
+ def _makePortal(self):
+ # Create a portal instance suitable for testing
factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
factory('site', 'CMFDefault:default', snapshot=False)
- site = self.root.site
+
+ return self.root.site
+
+ def test_join( self ):
+ site = self._makePortal()
member_id = 'test_user'
+
site.portal_registration.addMember( member_id
, 'zzyyzz'
, properties={ 'username': member_id
@@ -39,10 +45,27 @@
u = site.acl_users.getUser(member_id)
self.failUnless(u)
+ def test_join_memberproperties(self):
+ # Make sure the member data wrapper carries correct properties
+ # after joining
+ site = self._makePortal()
+ member_id = 'test_user'
+
+ site.portal_registration.addMember( member_id
+ , 'zzyyzz'
+ , properties={ 'username': member_id
+ , 'email' : 'foo at bar.com'
+ }
+ )
+
+ m = site.portal_membership.getMemberById('test_user')
+ self.assertEqual(m.getProperty('email'), 'foo at bar.com')
+ self.assertEqual(m.getMemberId(), member_id)
+ self.assertEqual(m.getRoles(), ('Member', 'Authenticated'))
+
def test_join_without_email( self ):
- factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
- factory('site', 'CMFDefault:default', snapshot=False)
- site = self.root.site
+ site = self._makePortal()
+
self.assertRaises(ValueError,
site.portal_registration.addMember,
'test_user',
@@ -51,9 +74,7 @@
)
def test_join_with_variable_id_policies( self ):
- factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
- factory('site', 'CMFDefault:default', snapshot=False)
- site = self.root.site
+ site = self._makePortal()
member_id = 'test.user'
# Test with the default policy: Names with "." should fail
@@ -67,7 +88,6 @@
)
# Now change the policy to allow "."
- #import pdb; pdb.set_trace()
new_pattern = "^[A-Za-z][A-Za-z0-9_\.]*$"
site.portal_registration.manage_editIDPattern(new_pattern)
site.portal_registration.addMember( member_id
More information about the CMF-checkins
mailing list