[Erp5-report] r24050 - in /erp5/trunk/products/ERP5: Document/Alarm.py tests/testAlarm.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Oct 7 12:13:19 CEST 2008
Author: seb
Date: Tue Oct 7 12:13:15 2008
New Revision: 24050
URL: http://svn.erp5.org?rev=24050&view=rev
Log:
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
Modified:
erp5/trunk/products/ERP5/Document/Alarm.py
erp5/trunk/products/ERP5/tests/testAlarm.py
Modified: erp5/trunk/products/ERP5/Document/Alarm.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Alarm.py?rev=24050&r1=24049&r2=24050&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Alarm.py (original)
+++ erp5/trunk/products/ERP5/Document/Alarm.py Tue Oct 7 12:13:15 2008
@@ -180,6 +180,9 @@
next_start_date = addToDate(next_start_date, hour=1)
else:
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)
else:
# Everything is right, but the date is still not bigger
Modified: erp5/trunk/products/ERP5/tests/testAlarm.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testAlarm.py?rev=24050&r1=24049&r2=24050&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testAlarm.py (original)
+++ erp5/trunk/products/ERP5/tests/testAlarm.py Tue Oct 7 12:13:15 2008
@@ -245,10 +245,11 @@
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
- right_first_date = DateTime(self.date_format % (2006,10,7,14,00,00))
- right_second_date = DateTime(self.date_format % (2006,10,7,15,00,00))
- right_third_date = DateTime(self.date_format % (2006,10,7,17,00,00))
- right_fourth_date = DateTime(self.date_format % (2006,10,11,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,8,14,00,00))
+ right_third_date = DateTime(self.date_format % (2006,10,8,15,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.setPeriodicityStartDate(right_first_date)
alarm.setPeriodicityDayFrequency(4)
@@ -262,6 +263,8 @@
self.assertEquals(alarm.getAlarmDate(),right_third_date)
alarm.setNextAlarmDate(current_date=right_third_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):
"""- every monday and friday, at 6 and 15"""
@@ -272,9 +275,10 @@
LOG('Testing... ',0,message)
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_third_date = DateTime(self.date_format % (2006,10,2,6,00,00))
- right_fourth_date = DateTime(self.date_format % (2006,10,2,15,00,00))
+ right_second_date = DateTime(self.date_format % (2006,9,29,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,6,00,00))
+ right_fifth_date = DateTime(self.date_format % (2006,10,2,15,00,00))
alarm = self.newAlarm()
get_transaction().commit()
self.tic()
@@ -282,14 +286,6 @@
alarm.setPeriodicityWeekDayList(('Monday','Friday'))
alarm.setPeriodicityHourList((6,15))
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):
"""
More information about the Erp5-report
mailing list