Commit 0eb35870 authored by Vincent Pelletier's avatar Vincent Pelletier

testAlarm: Simplify.

Drop failed activities instead of retrying execution and expecting it to
both fail and do something (execute alarm, then index result).
parent 0ada13ed
...@@ -314,7 +314,6 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -314,7 +314,6 @@ class TestAlarm(ERP5TypeTestCase):
self.assertEqual(active_process, alarm.getLastActiveProcess()) self.assertEqual(active_process, alarm.getLastActiveProcess())
def test_15_FailedAlarmsDoNotBlockFutureAlarms(self): def test_15_FailedAlarmsDoNotBlockFutureAlarms(self):
try:
sense_method_id = 'Alarm_testSenseMethod' sense_method_id = 'Alarm_testSenseMethod'
skin_folder_id = 'custom' skin_folder_id = 'custom'
skin_folder = self.getPortal().portal_skins[skin_folder_id] skin_folder = self.getPortal().portal_skins[skin_folder_id]
...@@ -324,38 +323,27 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -324,38 +323,27 @@ class TestAlarm(ERP5TypeTestCase):
del skin_folder del skin_folder
alarm = self.newAlarm(enabled=True) alarm = self.newAlarm(enabled=True)
self.tic() self.tic()
now = DateTime()
alarm.setActiveSenseMethodId(sense_method_id) alarm.setActiveSenseMethodId(sense_method_id)
self.assertEqual(alarm.isActive(), 0) self.assertEqual(alarm.isActive(), 0)
alarm.activeSense() alarm.activeSense()
self.commit()
try: try:
self.tic() self.tic()
except RuntimeError: except RuntimeError:
pass try:
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. # Check that the alarm is not considered active, although there is a remaining activity.
self.assertEqual(alarm.hasActivity(), 1) self.assertEqual(alarm.hasActivity(), 1)
self.assertEqual(alarm.isActive(), 0) self.assertEqual(alarm.isActive(), 0)
self.assertEqual(alarm.getLastActiveProcess(), None) self.assertEqual(alarm.getLastActiveProcess(), None)
finally:
self.portal.portal_activities.manageClearActivities(keep=0)
else:
raise Exception, 'Tic did not raise though activity was supposed to fail'
# Make the sense method succeed and leave a trace # 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()') self.getPortal().portal_skins[skin_folder_id][sense_method_id].ZPythonScript_edit('*args,**kw', 'context.newActiveProcess()')
alarm.activeSense() alarm.activeSense()
self.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() 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 # Chen that the second alarm execution did happen
self.assertNotEquals(alarm.getLastActiveProcess(), None) self.assertNotEquals(alarm.getLastActiveProcess(), None)
finally:
self.portal.portal_activities.manageClearActivities(keep=0)
def test_16_uncatalog(self): def test_16_uncatalog(self):
""" """
......
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