diff --git a/product/ERP5/tests/testAlarm.py b/product/ERP5/tests/testAlarm.py index 6f0eaeeee7cc971b4c4b28e286ca85b8c482d693..ec20c874475e3995febdbdfef40c969f4c54336e 100644 --- a/product/ERP5/tests/testAlarm.py +++ b/product/ERP5/tests/testAlarm.py @@ -63,7 +63,7 @@ class TestAlarm(ERP5TypeTestCase): def getTitle(self): return "Alarm" - def afterSetUp(self, quiet=1, run=1): + def afterSetUp(self): self.login() def newAlarm(self): @@ -398,46 +398,49 @@ class TestAlarm(ERP5TypeTestCase): message = 'Test Failed Alarms Do Not Block Future Alarms' ZopeTestCase._print('\n%s ' % 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: + 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() - 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) + 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: + 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): """