Commit 9915a1df authored by Jérome Perrin's avatar Jérome Perrin

call self.portal.portal_activities.manageClearActivities not to leave any failed messages


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19050 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e6110f2d
...@@ -63,7 +63,7 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -63,7 +63,7 @@ class TestAlarm(ERP5TypeTestCase):
def getTitle(self): def getTitle(self):
return "Alarm" return "Alarm"
def afterSetUp(self, quiet=1, run=1): def afterSetUp(self):
self.login() self.login()
def newAlarm(self): def newAlarm(self):
...@@ -398,46 +398,49 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -398,46 +398,49 @@ class TestAlarm(ERP5TypeTestCase):
message = 'Test Failed Alarms Do Not Block Future Alarms' message = 'Test Failed Alarms Do Not Block Future Alarms'
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
sense_method_id = 'Alarm_testSenseMethod'
skin_folder_id = 'custom'
skin_folder = self.getPortal().portal_skins[skin_folder_id]
skin_folder.manage_addProduct['PythonScripts'].manage_addPythonScript(id=sense_method_id)
# Make the sense method fail
skin_folder[sense_method_id].ZPythonScript_edit('*args,**kw', 'raise Exception')
del skin_folder
alarm = self.newAlarm()
get_transaction().commit()
self.tic()
now = DateTime()
alarm.setActiveSenseMethodId(sense_method_id)
self.assertEquals(alarm.isActive(), 0)
alarm.activeSense()
get_transaction().commit()
try:
self.tic()
except RuntimeError:
pass
else:
raise Exception, 'Tic did not raise though activity was supposed to fail'
# Check that the alarm is not considered active, although there is a remaining activity.
self.assertEquals(alarm.hasActivity(), 1)
self.assertEquals(alarm.isActive(), 0)
self.assertEquals(alarm.getLastActiveProcess(), None)
# Make the sense method succeed and leave a trace
self.getPortal().portal_skins[skin_folder_id][sense_method_id].ZPythonScript_edit('*args,**kw', 'context.newActiveProcess()')
alarm.activeSense()
get_transaction().commit()
# Note: this call to tic will fail, because the previous message is still there
# This behaviour is logical if we consider that we want to keep errors
# in order to know that an error occured.
try: try:
sense_method_id = 'Alarm_testSenseMethod'
skin_folder_id = 'custom'
skin_folder = self.getPortal().portal_skins[skin_folder_id]
skin_folder.manage_addProduct['PythonScripts'].manage_addPythonScript(id=sense_method_id)
# Make the sense method fail
skin_folder[sense_method_id].ZPythonScript_edit('*args,**kw', 'raise Exception')
del skin_folder
alarm = self.newAlarm()
get_transaction().commit()
self.tic() self.tic()
except RuntimeError: now = DateTime()
pass alarm.setActiveSenseMethodId(sense_method_id)
else: self.assertEquals(alarm.isActive(), 0)
raise Exception, 'Tic did not raise though activity was supposed to fail' alarm.activeSense()
# Chen that the second alarm execution did happen get_transaction().commit()
self.assertNotEquals(alarm.getLastActiveProcess(), None) try:
self.tic()
except RuntimeError:
pass
else:
raise Exception, 'Tic did not raise though activity was supposed to fail'
# Check that the alarm is not considered active, although there is a remaining activity.
self.assertEquals(alarm.hasActivity(), 1)
self.assertEquals(alarm.isActive(), 0)
self.assertEquals(alarm.getLastActiveProcess(), None)
# Make the sense method succeed and leave a trace
self.getPortal().portal_skins[skin_folder_id][sense_method_id].ZPythonScript_edit('*args,**kw', 'context.newActiveProcess()')
alarm.activeSense()
get_transaction().commit()
# Note: this call to tic will fail, because the previous message is still there
# This behaviour is logical if we consider that we want to keep errors
# in order to know that an error occured.
try:
self.tic()
except RuntimeError:
pass
else:
raise Exception, 'Tic did not raise though activity was supposed to fail'
# Chen that the second alarm execution did happen
self.assertNotEquals(alarm.getLastActiveProcess(), None)
finally:
self.portal.portal_activities.manageClearActivities(keep=0)
def test_16_uncatalog(self, quiet=0, run=run_all_test): def test_16_uncatalog(self, quiet=0, run=run_all_test):
""" """
......
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