def test_week_schedule_with_same_day(): wednesday = 2 s = schedule.WeekSchedule(wednesday, datetime.time(12, 30)) now = datetime.datetime(2018, 3, 7, 12, 29, 59, 999999) # this is a wednesday next_expected = datetime.datetime(2018, 3, 7, 12, 30) assert s.next(now) == next_expected last_expected = datetime.datetime(2018, 2, 28, 12, 30) assert s.last(now) == last_expected
def test_week_schedule(): monday = 0 s = schedule.WeekSchedule(monday, datetime.time(9, 0)) now = datetime.datetime(2018, 3, 7, 10, 12, 32) next_expected = datetime.datetime(2018, 3, 12, 9, 0) assert s.next(now) == next_expected last_expected = datetime.datetime(2018, 3, 5, 9, 0) assert s.last(now) == last_expected