def test_monthweekdaydaterange_start_end_time(self): """ Test MonthWeekDayDaterange.get_start_and_end_time to get start and end date of date range :return: None """ data = {} local_offset = time.timezone - 3600 * time.daylight # TS below are for UTC local_hour_offset = local_offset / 3600 if local_hour_offset >= 0: local_hour_offset = "-%02d" % local_hour_offset else: local_hour_offset = "+%02d" % -local_hour_offset for num in xrange(1, 31): data['2015-07-%02d 01:50:00 %s' % (num, local_hour_offset)] = { 'start': 1436832000 + local_offset, 'end': 1440201599 + local_offset } for num in xrange(1, 21): data['2015-08-%02d 01:50:00 %s' % (num, local_hour_offset)] = { 'start': 1436832000 + local_offset, 'end': 1440201599 + local_offset } for num in xrange(22, 31): data['2015-08-%02d 01:50:00 %s ' % (num, local_hour_offset)] = { 'start': 1468281600 + local_offset, 'end': 1471651199 + local_offset } # 2nd tuesday of July 2015 => 14 # 3rd friday of August 2015 => 21 # next : 2nd tuesday of July 2016 => 12 # next 3rd friday of August 2016 => 19 params = {'syear': 2015, 'smon': 7, 'smday': 0, 'swday': 1, 'swday_offset': 2, 'eyear': 2015, 'emon': 8, 'emday': 0, 'ewday': 4, 'ewday_offset': 3, 'skip_interval': 0, 'other': ''} caldate = MonthWeekDayDaterange(params) for date_now in data: with freeze_time(date_now, tz_offset=0): ret = caldate.get_start_and_end_time() print "* %s" % date_now assert data[date_now]['start'] == ret[0] assert data[date_now]['end'] == ret[1]
def test_monthweekdaydaterange_start_end_time(self): """ Test MonthWeekDayDaterange.get_start_and_end_time to get start and end date of date range :return: None """ data = {} local_offset = time.timezone - 3600 * time.daylight # TS below are for UTC local_hour_offset = local_offset / 3600 if local_hour_offset >= 0: local_hour_offset = "-%02d" % local_hour_offset else: local_hour_offset = "+%02d" % -local_hour_offset for num in range(1, 31): data['2015-07-%02d 01:50:00 %s' % (num, local_hour_offset)] = { 'start': 1436832000 + local_offset, 'end': 1440201599 + local_offset } for num in range(1, 21): data['2015-08-%02d 01:50:00 %s' % (num, local_hour_offset)] = { 'start': 1436832000 + local_offset, 'end': 1440201599 + local_offset } for num in range(22, 31): data['2015-08-%02d 01:50:00 %s ' % (num, local_hour_offset)] = { 'start': 1468281600 + local_offset, 'end': 1471651199 + local_offset } # 2nd tuesday of July 2015 => 14 # 3rd friday of August 2015 => 21 # next : 2nd tuesday of July 2016 => 12 # next 3rd friday of August 2016 => 19 params = {'syear': 2015, 'smon': 7, 'smday': 0, 'swday': 1, 'swday_offset': 2, 'eyear': 2015, 'emon': 8, 'emday': 0, 'ewday': 4, 'ewday_offset': 3, 'skip_interval': 0, 'other': ''} caldate = MonthWeekDayDaterange(params) for date_now in data: with freeze_time(date_now, tz_offset=0): ret = caldate.get_start_and_end_time() print("* %s" % date_now) assert data[date_now]['start'] == ret[0] assert data[date_now]['end'] == ret[1]
def test_MonthWeekDayDaterange_start_end_time(self): data = {} local_offset = time.timezone - 3600 * time.daylight #TS below are for UTC local_hour_offset = local_offset / 3600 if local_hour_offset >= 0: local_hour_offset = "-%02d" % local_hour_offset else: local_hour_offset = "+%02d" % -local_hour_offset for x in xrange(1, 31): data['2015-07-%02d 01:50:00 %s' % (x, local_hour_offset)] = { 'start': 1436832000 + local_offset, 'end': 1440201599 + local_offset } for x in xrange(1, 21): data['2015-08-%02d 01:50:00 %s' % (x, local_hour_offset)] = { 'start': 1436832000 + local_offset, 'end': 1440201599 + local_offset } for x in xrange(22, 31): data['2015-08-%02d 01:50:00 %s ' % (x, local_hour_offset)] = { 'start': 1468281600 + local_offset, 'end': 1471651199 + local_offset } # 2nd tuesday of July 2015 => 14 # 3rd friday of August 2015 => 21 # next : 2nd tuesday of July 2016 => 12 # next 3rd friday of August 2016 => 19 caldate = MonthWeekDayDaterange(2015, 7, 0, 1, 2, 2015, 8, 0, 4, 3, 0, '') for date_now in data: with freeze_time(date_now, tz_offset=0): ret = caldate.get_start_and_end_time() print "* %s" % date_now self.assertEqual(data[date_now]['start'], ret[0]) self.assertEqual(data[date_now]['end'], ret[1])
def test_MonthWeekDayDaterange_start_end_time(self): data = {} local_offset = time.timezone - 3600 * time.daylight #TS below are for UTC local_hour_offset = local_offset / 3600 if local_hour_offset >= 0: local_hour_offset = "-%02d" % local_hour_offset else: local_hour_offset = "+%02d" % -local_hour_offset for x in xrange(1, 31): data['2015-07-%02d 01:50:00 %s' % (x, local_hour_offset)] = { 'start': 1436832000 + local_offset, 'end': 1440201599 + local_offset } for x in xrange(1, 21): data['2015-08-%02d 01:50:00 %s' % (x, local_hour_offset)] = { 'start': 1436832000 + local_offset, 'end': 1440201599 + local_offset } for x in xrange(22, 31): data['2015-08-%02d 01:50:00 %s ' % (x, local_hour_offset)] = { 'start': 1468281600 + local_offset, 'end': 1471651199 + local_offset } # 2nd tuesday of July 2015 => 14 # 3rd friday of August 2015 => 21 # next : 2nd tuesday of July 2016 => 12 # next 3rd friday of August 2016 => 19 caldate = MonthWeekDayDaterange(2015, 7, 0, 1, 2, 2015, 8, 0, 4, 3, 0, '') for date_now in data: with freeze_time(date_now, tz_offset=0): ret = caldate.get_start_and_end_time() print "* %s" % date_now self.assertEqual(data[date_now]['start'], ret[0]) self.assertEqual(data[date_now]['end'], ret[1])