Commit 6e715b82 authored by Sebastien Robin's avatar Sebastien Robin

Fixed 2 tests in testAlarm :

- test_08_SomeWeekDaysSomeHours was wrong, one date was missing, and
  this test was working before because of error in implementation
- test_07a_Every4DaysSomeHours was expecting that alarm dates takes
  into account initial start time, this is not implemented like this
  and current implementation is probably enough, so I changed values.
Fixed Alarm.py :
- When we add a day, we should reset hours and minutes, otherwise
  we can forget several matching dates, it might be required to
  do the same thing when adding one hour


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24050 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 58a3da3b
...@@ -180,6 +180,9 @@ class PeriodicityMixin: ...@@ -180,6 +180,9 @@ class PeriodicityMixin:
next_start_date = addToDate(next_start_date, hour=1) next_start_date = addToDate(next_start_date, hour=1)
else: else:
if not(validate_day and validate_week and validate_month): if not(validate_day and validate_week and validate_month):
# We have to reset hours and minutes in order to make sure
# we will start at the beginning of the next day
next_start_date = DateTime(next_start_date.strftime('%Y/%m/%d') + ' 00:00:00 %s' % next_start_date.timezone())
next_start_date = addToDate(next_start_date, day=1) next_start_date = addToDate(next_start_date, day=1)
else: else:
# Everything is right, but the date is still not bigger # Everything is right, but the date is still not bigger
......
...@@ -245,10 +245,11 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -245,10 +245,11 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
right_first_date = DateTime(self.date_format % (2006,10,7,14,00,00)) right_first_date = DateTime(self.date_format % (2006,10,7,13,00,00))
right_second_date = DateTime(self.date_format % (2006,10,7,15,00,00)) right_second_date = DateTime(self.date_format % (2006,10,8,14,00,00))
right_third_date = DateTime(self.date_format % (2006,10,7,17,00,00)) right_third_date = DateTime(self.date_format % (2006,10,8,15,00,00))
right_fourth_date = DateTime(self.date_format % (2006,10,11,14,00,00)) right_fourth_date = DateTime(self.date_format % (2006,10,8,17,00,00))
right_fifth_date = DateTime(self.date_format % (2006,10,12,14,00,00))
alarm = self.newAlarm() alarm = self.newAlarm()
alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityStartDate(right_first_date)
alarm.setPeriodicityDayFrequency(4) alarm.setPeriodicityDayFrequency(4)
...@@ -262,6 +263,8 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -262,6 +263,8 @@ class TestAlarm(ERP5TypeTestCase):
self.assertEquals(alarm.getAlarmDate(),right_third_date) self.assertEquals(alarm.getAlarmDate(),right_third_date)
alarm.setNextAlarmDate(current_date=right_third_date) alarm.setNextAlarmDate(current_date=right_third_date)
self.assertEquals(alarm.getAlarmDate(),right_fourth_date) self.assertEquals(alarm.getAlarmDate(),right_fourth_date)
alarm.setNextAlarmDate(current_date=right_fourth_date)
self.assertEquals(alarm.getAlarmDate(),right_fifth_date)
def test_08_SomeWeekDaysSomeHours(self, quiet=0, run=run_all_test): def test_08_SomeWeekDaysSomeHours(self, quiet=0, run=run_all_test):
"""- every monday and friday, at 6 and 15""" """- every monday and friday, at 6 and 15"""
...@@ -272,9 +275,10 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -272,9 +275,10 @@ class TestAlarm(ERP5TypeTestCase):
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
right_first_date = DateTime(self.date_format % (2006,9,27,6,00,00)) right_first_date = DateTime(self.date_format % (2006,9,27,6,00,00))
right_second_date = DateTime(self.date_format % (2006,9,29,15,00,00)) right_second_date = DateTime(self.date_format % (2006,9,29,6,00,00))
right_third_date = DateTime(self.date_format % (2006,10,2,6,00,00)) right_third_date = DateTime(self.date_format % (2006,9,29,15,00,00))
right_fourth_date = DateTime(self.date_format % (2006,10,2,15,00,00)) right_fourth_date = DateTime(self.date_format % (2006,10,2,6,00,00))
right_fifth_date = DateTime(self.date_format % (2006,10,2,15,00,00))
alarm = self.newAlarm() alarm = self.newAlarm()
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
...@@ -282,14 +286,6 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -282,14 +286,6 @@ class TestAlarm(ERP5TypeTestCase):
alarm.setPeriodicityWeekDayList(('Monday','Friday')) alarm.setPeriodicityWeekDayList(('Monday','Friday'))
alarm.setPeriodicityHourList((6,15)) alarm.setPeriodicityHourList((6,15))
self.checkDate(alarm, right_first_date, right_second_date, right_third_date, right_fourth_date) self.checkDate(alarm, right_first_date, right_second_date, right_third_date, right_fourth_date)
#self.assertEquals(alarm.getAlarmDate(),right_first_date)
#alarm.setNextAlarmDate(current_date=right_first_date)
#self.assertEquals(alarm.getAlarmDate(),right_second_date)
#alarm.setNextAlarmDate(current_date=right_second_date)
#self.assertEquals(alarm.getAlarmDate(),right_third_date)
#alarm.setNextAlarmDate(current_date=right_third_date)
#self.assertEquals(alarm.getAlarmDate(),right_fourth_date)
def checkDate(self,alarm,*args): def checkDate(self,alarm,*args):
""" """
......
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