Commit 117c998e authored by Sebastien Robin's avatar Sebastien Robin

- Do not make tic on activity tool failing when the periodicity

start date is not working.
- Add a test to show that tic is working on alarm tool even if
  a periodicity start date is not defined on a particular alarm


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20288 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ca143233
......@@ -510,17 +510,16 @@ Alarm URL: %s
"""
returns something like ['Sunday','Monday',...]
"""
#alarm_date = self._baseGetAlarmDate()
#if alarm_date is None:
# alarm_date = self.getPeriodicityStartDate()
alarm_date=None
result_list = self.Alarm_zGetAlarmDate(uid=self.getUid())
if len(result_list)==1:
alarm_date = result_list[0].alarm_date
periodicity_start_date = self.getPeriodicityStartDate()
if alarm_date < periodicity_start_date:
alarm_date = periodicity_start_date
# convert the date to the user provided timezone
alarm_zone = periodicity_start_date.timezone()
alarm_date = alarm_date.toZone(alarm_zone)
# No periodicity start date, return None
if self.getPeriodicityStartDate() is not None:
result_list = self.Alarm_zGetAlarmDate(uid=self.getUid())
if len(result_list)==1:
alarm_date = result_list[0].alarm_date
periodicity_start_date = self.getPeriodicityStartDate()
if alarm_date < periodicity_start_date:
alarm_date = periodicity_start_date
# convert the date to the user provided timezone
alarm_zone = periodicity_start_date.timezone()
alarm_date = alarm_date.toZone(alarm_zone)
return alarm_date
......@@ -444,7 +444,7 @@ class TestAlarm(ERP5TypeTestCase):
def test_16_uncatalog(self, quiet=0, run=run_all_test):
"""
Check that deleting a alarm uncatalogs it.
Check that deleting an alarm uncatalogs it.
"""
if not run: return
if not quiet:
......@@ -480,6 +480,47 @@ class TestAlarm(ERP5TypeTestCase):
result = sql_connection.manage_test(sql)
self.assertEquals(0, len(result))
def test_17_tic(self, quiet=0, run=run_all_test):
"""
Make sure that the tic method on alarm is working
"""
if not run: return
if not quiet:
message = 'Test AlarmTool Tic'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
alarm = self.newAlarm()
alarm.setEnabled(True)
get_transaction().commit()
self.tic()
get_transaction().commit()
self.tic()
sense_method_id = 'Alarm_testSenseMethodForTic'
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',
'context.setDescription("a")')
del skin_folder
alarm.setActiveSenseMethodId(sense_method_id)
get_transaction().commit()
self.tic()
alarm_tool = self.getPortal().portal_alarms
# Nothing should happens yet
alarm_tool.tic()
self.assertTrue(alarm.getDescription() in (None, ''))
now = DateTime()
date = addToDate(now, day=1)
alarm.setPeriodicityStartDate(date)
alarm.setPeriodicityMinuteFrequency(1)
get_transaction().commit()
self.tic()
alarm_tool.tic()
self.assertEquals(alarm.getDescription(), 'a')
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestAlarm))
......
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