Commit 6b83d2b1 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

cleanup test file.

parent 1c84ec2a
...@@ -29,9 +29,7 @@ ...@@ -29,9 +29,7 @@
import unittest import unittest
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from DateTime import DateTime from DateTime import DateTime
...@@ -39,16 +37,12 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -39,16 +37,12 @@ class TestPasswordTool(ERP5TypeTestCase):
""" """
Test reset of password Test reset of password
""" """
run_all_test = 1
quiet = 1
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
return ('erp5_base', ) return ('erp5_base', )
def getTitle(self): def getTitle(self):
return "Password Tool" return "Password Tool"
def afterSetUp(self): def afterSetUp(self):
self.portal.email_from_address = 'site@example.invalid' self.portal.email_from_address = 'site@example.invalid'
self.portal.MailHost.reset() self.portal.MailHost.reset()
...@@ -168,7 +162,6 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -168,7 +162,6 @@ class TestPasswordTool(ERP5TypeTestCase):
self.assertEquals('Portal Administrator <site@example.invalid>', mfrom) self.assertEquals('Portal Administrator <site@example.invalid>', mfrom)
self.assertEquals(['userA@example.invalid'], mto) self.assertEquals(['userA@example.invalid'], mto)
def stepGoToRandomAddress(self, sequence=None, sequence_list=None, **kw): def stepGoToRandomAddress(self, sequence=None, sequence_list=None, **kw):
""" """
Call method that change the password Call method that change the password
...@@ -183,7 +176,6 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -183,7 +176,6 @@ class TestPasswordTool(ERP5TypeTestCase):
# reset cache # reset cache
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
def stepGoToRandomAddressWithBadUserName(self, sequence=None, sequence_list=None, **kw): def stepGoToRandomAddressWithBadUserName(self, sequence=None, sequence_list=None, **kw):
""" """
Call method that change the password with a bad user name Call method that change the password with a bad user name
...@@ -198,7 +190,6 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -198,7 +190,6 @@ class TestPasswordTool(ERP5TypeTestCase):
# reset cache # reset cache
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
def stepGoToRandomAddressTwice(self, sequence=None, sequence_list=None, **kw): def stepGoToRandomAddressTwice(self, sequence=None, sequence_list=None, **kw):
""" """
As we already change password, this must npot work anylonger As we already change password, this must npot work anylonger
...@@ -211,7 +202,6 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -211,7 +202,6 @@ class TestPasswordTool(ERP5TypeTestCase):
# reset cache # reset cache
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
def stepGoToBadRandomAddress(self, sequence=None, sequence_list=None, **kw): def stepGoToBadRandomAddress(self, sequence=None, sequence_list=None, **kw):
""" """
Try to reset a password with bad random part Try to reset a password with bad random part
...@@ -224,7 +214,6 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -224,7 +214,6 @@ class TestPasswordTool(ERP5TypeTestCase):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
def stepModifyExpirationDate(self, sequence=None, sequence_list=None, **kw): def stepModifyExpirationDate(self, sequence=None, sequence_list=None, **kw):
""" """
Change expiration date so that reset of password is not available Change expiration date so that reset of password is not available
...@@ -250,7 +239,6 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -250,7 +239,6 @@ class TestPasswordTool(ERP5TypeTestCase):
""" """
self.assertEqual(len(self.portal.portal_password._password_request_dict), 0) self.assertEqual(len(self.portal.portal_password._password_request_dict), 0)
def stepLogout(self, sequence=None, sequence_list=None, **kw): def stepLogout(self, sequence=None, sequence_list=None, **kw):
""" """
Logout Logout
...@@ -258,12 +246,7 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -258,12 +246,7 @@ class TestPasswordTool(ERP5TypeTestCase):
self.logout() self.logout()
# tests # tests
def test_01_checkPasswordTool(self, quiet=quiet, run=run_all_test): def test_01_checkPasswordTool(self):
if not run: return
if not quiet:
message = 'Test Password Tool'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_string = 'CheckPasswordToolExists ' \ sequence_string = 'CheckPasswordToolExists ' \
'AddUser Tic ' \ 'AddUser Tic ' \
...@@ -282,15 +265,9 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -282,15 +265,9 @@ class TestPasswordTool(ERP5TypeTestCase):
'CheckUserNotLoginWithFormerPassword ' \ 'CheckUserNotLoginWithFormerPassword ' \
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def test_02_checkPasswordToolDateExpired(self, quiet=quiet, run=run_all_test): def test_02_checkPasswordToolDateExpired(self):
if not run: return
if not quiet:
message = 'Test no login reset if date expired'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_string = 'CheckPasswordToolExists ' \ sequence_string = 'CheckPasswordToolExists ' \
'AddUser Tic ' \ 'AddUser Tic ' \
...@@ -303,15 +280,9 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -303,15 +280,9 @@ class TestPasswordTool(ERP5TypeTestCase):
'CheckUserLogin CheckUserNotLoginWithBadPassword ' \ 'CheckUserLogin CheckUserNotLoginWithBadPassword ' \
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def test_03_checkPasswordToolAlarm(self, quiet=quiet, run=run_all_test): def test_03_checkPasswordToolAlarm(self):
if not run: return
if not quiet:
message = 'Test alarm remove expired request'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_string = 'CheckPasswordToolExists ' \ sequence_string = 'CheckPasswordToolExists ' \
'AddUser Tic ' \ 'AddUser Tic ' \
...@@ -326,7 +297,7 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -326,7 +297,7 @@ class TestPasswordTool(ERP5TypeTestCase):
'CheckUserLogin CheckUserNotLoginWithBadPassword ' \ 'CheckUserLogin CheckUserNotLoginWithBadPassword ' \
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def test_two_concurrent_password_reset(self): def test_two_concurrent_password_reset(self):
personA = self.portal.person_module.newContent(portal_type="Person", personA = self.portal.person_module.newContent(portal_type="Person",
...@@ -381,7 +352,6 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -381,7 +352,6 @@ class TestPasswordTool(ERP5TypeTestCase):
self._assertUserExists('userA', 'newA') self._assertUserExists('userA', 'newA')
self._assertUserExists('userB', 'newB') self._assertUserExists('userB', 'newB')
def test_login_with_trailing_space(self): def test_login_with_trailing_space(self):
person = self.portal.person_module.newContent(portal_type="Person", person = self.portal.person_module.newContent(portal_type="Person",
reference="userZ ", reference="userZ ",
...@@ -455,7 +425,6 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -455,7 +425,6 @@ class TestPasswordTool(ERP5TypeTestCase):
self.assertTrue("portal_status_message=User+user+does+not+have+an+email+"\ self.assertTrue("portal_status_message=User+user+does+not+have+an+email+"\
"address%2C+please+contact+site+administrator+directly" in str(ret)) "address%2C+please+contact+site+administrator+directly" in str(ret))
class TestPasswordToolWithCRM(TestPasswordTool): class TestPasswordToolWithCRM(TestPasswordTool):
""" """
Test reset of password Test reset of password
...@@ -467,7 +436,6 @@ class TestPasswordToolWithCRM(TestPasswordTool): ...@@ -467,7 +436,6 @@ class TestPasswordToolWithCRM(TestPasswordTool):
def getTitle(self): def getTitle(self):
return "Password Tool with CRM" return "Password Tool with CRM"
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPasswordTool)) suite.addTest(unittest.makeSuite(TestPasswordTool))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment