[Erp5-report] r19050 - /erp5/trunk/products/ERP5/tests/testAlarm.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Feb 5 13:39:40 CET 2008
Author: jerome
Date: Tue Feb 5 13:39:39 2008
New Revision: 19050
URL: http://svn.erp5.org?rev=19050&view=rev
Log:
call self.portal.portal_activities.manageClearActivities not to leave any failed messages
Modified:
erp5/trunk/products/ERP5/tests/testAlarm.py
Modified: erp5/trunk/products/ERP5/tests/testAlarm.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testAlarm.py?rev=19050&r1=19049&r2=19050&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testAlarm.py (original)
+++ erp5/trunk/products/ERP5/tests/testAlarm.py Tue Feb 5 13:39:39 2008
@@ -63,7 +63,7 @@
def getTitle(self):
return "Alarm"
- def afterSetUp(self, quiet=1, run=1):
+ def afterSetUp(self):
self.login()
def newAlarm(self):
@@ -398,46 +398,49 @@
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:
+ 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'
- # 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)
+ 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):
"""
More information about the Erp5-report
mailing list