Commit 188ed4de authored by Sebastien Robin's avatar Sebastien Robin

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11593 20353a03-c40f-0410-a6d1-a30d3c3de9de

parent d444ec9b
############################################################################## ##############################################################################
# #
# Copyright (c) 2004 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com> # Sebastien Robin <seb@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
...@@ -181,6 +181,10 @@ class Periodicity(Base): ...@@ -181,6 +181,10 @@ class Periodicity(Base):
else: else:
if not(validate_day and validate_week and validate_month): if not(validate_day and validate_week and validate_month):
next_start_date = addToDate(next_start_date,day=1) next_start_date = addToDate(next_start_date,day=1)
else:
# Everything is right, but the date is still not bigger
# than the current date, so we must continue
next_start_date = addToDate(next_start_date,minute=1)
self.Alarm_zUpdateAlarmDate(uid=self.getUid(),alarm_date=next_start_date) self.Alarm_zUpdateAlarmDate(uid=self.getUid(),alarm_date=next_start_date)
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2004 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com> # Sebastien Robin <seb@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
...@@ -199,11 +199,11 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -199,11 +199,11 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
# year/month/day hour:minute:second # year/month/day hour:minute:second
right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,6,15,00,00)) right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,15,00,00))
now = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,6,15,00,00)) now = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,15,00,00))
right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,6,21,00,00)) right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,21,00,00))
right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,7,06,00,00)) right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,7,06,00,00))
right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,7,10,00,00)) right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,7,10,00,00))
alarm = self.newAlarm() alarm = self.newAlarm()
hour_list = (6,10,15,21) hour_list = (6,10,15,21)
alarm.setPeriodicityStartDate(now) alarm.setPeriodicityStartDate(now)
...@@ -225,10 +225,10 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -225,10 +225,10 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
# year/month/day hour:minute:second # year/month/day hour:minute:second
now = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,6,10,00,00)) now = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,10,00,00))
right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,6,10,00,00)) right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,10,00,00))
right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,7,10,00,00)) right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,7,10,00,00))
right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,8,10,00,00)) right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,8,10,00,00))
alarm = self.newAlarm() alarm = self.newAlarm()
alarm.setPeriodicityStartDate(now) alarm.setPeriodicityStartDate(now)
alarm.setPeriodicityDayFrequency(1) alarm.setPeriodicityDayFrequency(1)
...@@ -249,10 +249,10 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -249,10 +249,10 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
# year/month/day hour:minute:second # year/month/day hour:minute:second
right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,6,14,00,00)) right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,14,00,00))
right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,6,15,00,00)) right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,15,00,00))
right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,6,17,00,00)) right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,17,00,00))
right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,9,14,00,00)) right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,9,14,00,00))
alarm = self.newAlarm() alarm = self.newAlarm()
alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityStartDate(right_first_date)
alarm.setPeriodicityDayFrequency(3) alarm.setPeriodicityDayFrequency(3)
...@@ -275,10 +275,10 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -275,10 +275,10 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
# year/month/day hour:minute:second # year/month/day hour:minute:second
right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,9,27,6,00,00)) right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,9,27,6,00,00))
right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,9,27,15,00,00)) right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,9,29,15,00,00))
right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,1,6,00,00)) right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,2,6,00,00))
right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,1,15,00,00)) right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,2,15,00,00))
alarm = self.newAlarm() alarm = self.newAlarm()
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
...@@ -313,10 +313,10 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -313,10 +313,10 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
# year/month/day hour:minute:second # year/month/day hour:minute:second
right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,01,12,00,00)) right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,01,12,00,00))
right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,01,14,00,00)) right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,01,14,00,00))
right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,15,12,00,00)) right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,15,12,00,00))
right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,15,14,00,00)) right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,15,14,00,00))
alarm = self.newAlarm() alarm = self.newAlarm()
alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityStartDate(right_first_date)
alarm.setPeriodicityMonthDayList((1,15)) alarm.setPeriodicityMonthDayList((1,15))
...@@ -333,9 +333,9 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -333,9 +333,9 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
# year/month/day hour:minute:second # year/month/day hour:minute:second
right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,01,6,00,00)) right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,01,6,00,00))
right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,12,01,6,00,00)) right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,12,01,6,00,00))
right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2005,2,01,6,00,00)) right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2007,2,01,6,00,00))
alarm = self.newAlarm() alarm = self.newAlarm()
alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityStartDate(right_first_date)
alarm.setPeriodicityMonthDayList((1,)) alarm.setPeriodicityMonthDayList((1,))
...@@ -352,10 +352,10 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -352,10 +352,10 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
# year/month/day hour:minute:second # year/month/day hour:minute:second
right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,10,6,00,00)) right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,1,6,00,00))
right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,18,6,00,00)) right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,9,6,00,00))
right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,19,6,00,00)) right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,10,6,00,00))
right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2004,10,20,6,00,00)) right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,11,6,00,00))
alarm = self.newAlarm() alarm = self.newAlarm()
alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityStartDate(right_first_date)
alarm.setPeriodicityHourList((6,)) alarm.setPeriodicityHourList((6,))
...@@ -392,6 +392,22 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -392,6 +392,22 @@ class TestAlarm(ERP5TypeTestCase):
next_date = addToDate(next_date,minute=5) next_date = addToDate(next_date,minute=5)
self.assertEquals(alarm.getAlarmDate(),next_date) self.assertEquals(alarm.getAlarmDate(),next_date)
def test_13_EveryMinute(self, quiet=0, run=run_all_test):
if not run: return
if not quiet:
message = 'Test Every Minute'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
alarm = self.newAlarm()
now = DateTime()
date = addToDate(now,hour=2)
alarm.setPeriodicityStartDate(now)
alarm.setPeriodicityMinuteFrequency(1)
get_transaction().commit()
self.tic()
alarm.setNextAlarmDate(current_date=date)
self.assertEquals(alarm.getAlarmDate(),date)
if __name__ == '__main__': if __name__ == '__main__':
framework() framework()
else: else:
......
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