예제 #1
0
def test_startmonth_schedule():
    s = schedule.StartMonthSchedule(3, datetime.time(12, 30))
    now = datetime.datetime(2018, 3, 7, 10, 12, 32)

    next_expected = datetime.datetime(2018, 4, 3, 12, 30)
    assert s.next(now) == next_expected

    last_expected = datetime.datetime(2018, 3, 3, 12, 30)
    assert s.last(now) == last_expected
예제 #2
0
def test_startmonth_schedule_on_same_day():
    # If the actual time matches the schedule exactly the
    # the next date equals the actual time.
    s = schedule.StartMonthSchedule(7, datetime.time(12, 30))
    now = datetime.datetime(2018, 3, 7, 12, 30, 1)

    next_expected = datetime.datetime(2018, 4, 7, 12, 30)
    assert s.next(now) == next_expected

    last_expected = datetime.datetime(2018, 3, 7, 12, 30)
    assert s.last(now) == last_expected
예제 #3
0
def test_startmonth_schedule_with_large_day():
    # This test contains a switch to the daylight saving time
    # which was a problem in previous version.
    s = schedule.StartMonthSchedule(31, datetime.time(12, 30))
    now = datetime.datetime(2018, 3, 7, 10, 12, 32)

    next_expected = datetime.datetime(2018, 3, 31, 12, 30)
    assert s.next(now) == next_expected

    last_expected = datetime.datetime(2018, 1, 31, 12, 30)
    assert s.last(now) == last_expected
예제 #4
0
def test_startmonth_schedule_next_month_fewer_days():
    # Large days may lead to unexpected behaviour.
    # If day is to large months with fewer days are skipped.
    # This is conformant with the iCalendar RFC:
    # https://tools.ietf.org/html/rfc5545 (section 3.3.10).
    # For these cases the EndMonthSchedule should be used.
    s = schedule.StartMonthSchedule(31, datetime.time(12, 30))
    now = datetime.datetime(2018, 3, 31, 13, 00, 00)

    next_expected = datetime.datetime(2018, 5, 31, 12, 30)
    assert s.next(now) == next_expected

    last_expected = datetime.datetime(2018, 3, 31, 12, 30)
    assert s.last(now) == last_expected