def test_one_hour_period_2m_minus3m(self): job_times = scheduling_parser.JobTimes(60, [2, -3], 0) dts = job_times.next_times(datetime.datetime(2015, 12, 10, 0, 0, 1), 5) self.assertEqual(dts, [ datetime.datetime(2015, 12, 10, 0, 2, 0, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 57, 0, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 1, 2, 0, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 1, 57, 0, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 2, 2, 0, tzinfo=pytz.UTC), ])
def test_two_week_period(self): job_times = scheduling_parser.JobTimes(2 * 7 * 24 * 60, [0], 0) dts = job_times.next_times(datetime.datetime(2015, 12, 10, 0, 0, 1), 5) self.assertEqual(dts, [ datetime.datetime(2015, 12, 21, 0, 0, 0, tzinfo=pytz.UTC), datetime.datetime(2016, 1, 4, 0, 0, 0, tzinfo=pytz.UTC), datetime.datetime(2016, 1, 18, 0, 0, 0, tzinfo=pytz.UTC), datetime.datetime(2016, 2, 1, 0, 0, 0, tzinfo=pytz.UTC), datetime.datetime(2016, 2, 15, 0, 0, 0, tzinfo=pytz.UTC) ])
def test_minute_period_with_offset_and_jitter(self): job_times = scheduling_parser.JobTimes(5, [1], 2) dts = job_times.next_times(datetime.datetime(2015, 12, 10, 0, 0, 1), 5) self.assertEqual(dts, [ datetime.datetime(2015, 12, 10, 0, 1, 2, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 6, 2, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 11, 2, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 16, 2, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 21, 2, tzinfo=pytz.UTC) ])
def test_minute_period_with_jitter(self): job_times = scheduling_parser.JobTimes(5, [], 3) dts = job_times.next_times(datetime.datetime(2015, 12, 10, 0, 0, 1), 5) self.assertEqual(dts, [ datetime.datetime(2015, 12, 10, 0, 0, 3, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 5, 3, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 10, 3, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 15, 3, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 20, 3, tzinfo=pytz.UTC) ])
def test_minute_period_with_negative_offset(self): job_times = scheduling_parser.JobTimes(5, [-1], 0) dts = job_times.next_times(datetime.datetime(2015, 12, 10, 0, 0, 1), 5) self.assertEqual(dts, [ datetime.datetime(2015, 12, 10, 0, 4, 0, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 9, 0, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 14, 0, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 19, 0, tzinfo=pytz.UTC), datetime.datetime(2015, 12, 10, 0, 24, 0, tzinfo=pytz.UTC) ])