[CMF-checkins] CVS: CMF/CMFDefault/tests - test_RegistrationTool.py:1.2.24.2
Tres Seaver
tseaver@zope.com
Tue, 15 Apr 2003 13:08:34 -0400
Update of /cvs-repository/CMF/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv21462/CMFDefault/tests
Modified Files:
Tag: tseaver-reg_properties-branch
test_RegistrationTool.py
Log Message:
- Undo regression of Collector #48.
- Add test for #48. :)
- Add minimal test of 'testPasswordValidity'.
=== CMF/CMFDefault/tests/test_RegistrationTool.py 1.2.24.1 => 1.2.24.2 ===
--- CMF/CMFDefault/tests/test_RegistrationTool.py:1.2.24.1 Tue Apr 15 12:47:02 2003
+++ CMF/CMFDefault/tests/test_RegistrationTool.py Tue Apr 15 13:08:33 2003
@@ -1,14 +1,22 @@
from unittest import TestCase, TestSuite, makeSuite, main
import Zope
+
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.tests.base.testcase import TransactionalTest
+
+class DummyMembershipTool:
+
+ def getMemberById( self, id ):
+
+ return None
-class RegistrationToolTests(TestCase):
+class RegistrationToolTests(TransactionalTest):
def _getTargetClass(self):
from Products.CMFDefault.RegistrationTool import RegistrationTool
@@ -27,10 +35,37 @@
verifyClass(IRegistrationTool, self._getTargetClass())
verifyClass(IActionProvider, self._getTargetClass())
- def test_minPasswordLength(self):
+ def test_testPasswordValidity_min_password_length(self):
tool = self._makeOne()
+ error = tool.testPasswordValidity( 'abc', 'abc' )
+ self.failIf( error is None )
+
+ tool.min_password_length = 3
+ error = tool.testPasswordValidity( 'abc', 'abc' )
+ self.failUnless( error is None )
+
+ def test_testPropertiesValidity(self):
+
+ tool = self._makeOne().__of__( self.root )
+ self.root.portal_membership = DummyMembershipTool()
+
+ error = tool.testPropertiesValidity( { 'username' : '_abc'
+ } )
+
+ self.failIf( error is None )
+
+ error = tool.testPropertiesValidity( { 'username' : 'abc'
+ } )
+
+ self.failIf( error is None )
+
+ error = tool.testPropertiesValidity( { 'username' : 'abc'
+ , 'email' : 'foo@example.com'
+ } )
+
+ self.failUnless( error is None, error )
def test_suite():