def testPeriodicTaskNoMoreLeft(self): dt = datetime(2010, 1, 1, 20, 0, 0) # date + 1 month pt = PeriodicTask(rrule.YEARLY, dtstart=dt, until=dt + timedelta(days=30)) self.assertEqual(pt.getStartOn(), datetime(2010, 1, 1, 20, 0, 0)) pt.setNextOccurrence(dateAfter=dt) self.assertEqual(pt.getStartOn(), None) pt.setNextOccurrence(dateAfter=dt) self.assertEqual(pt.getStartOn(), None)
def testPeriodicTaskFrequency(self): dt = datetime(2010, 1, 1, 20, 0, 0) pt = PeriodicTask(rrule.MINUTELY, dtstart=dt) self.assertEqual(pt.getStartOn(), datetime(2010, 1, 1, 20, 0, 0)) pt.setNextOccurrence(dateAfter=dt) self.assertEqual(pt.getStartOn(), datetime(2010, 1, 1, 20, 1, 0)) pt = PeriodicTask(rrule.HOURLY, dtstart=dt) self.assertEqual(pt.getStartOn(), datetime(2010, 1, 1, 20, 0, 0)) pt.setNextOccurrence(dateAfter=dt) self.assertEqual(pt.getStartOn(), datetime(2010, 1, 1, 21, 0, 0))