Пример #1
0
def test_relative_time(relative):
    relative_dur = Minutes(int(relative))
    expected = Time(*now()) + relative_dur

    result = from_user_time(relative, cutoff_time(7))

    assert_that(result, equal_to(expected))
Пример #2
0
def test_rejects_bad_time1():
    time_text = "24:10"
    try:
        result = from_user_time(time_text, cutoff_time(7))
        raise AssertionError(
            "Expected to see a ValueError that the time is invalid")
    except ValueError:
        pass
Пример #3
0
def test_rejects_bad_ampm3():
    time_text = "13:30AM"
    try:
        result = from_user_time(time_text, cutoff_time(7))
        raise AssertionError(
            f"Expected to see a ValueError that the time is invalid, but got {result}"
        )
    except ValueError:
        pass
Пример #4
0
def test_cutoff_before():
    time_text = "6:59"
    result = from_user_time(time_text, cutoff_time(7))

    assert_that(result, equal_to(Time(18, 59)))
Пример #5
0
def test_cutoff_after():
    time_text = "7:15"
    result = from_user_time(time_text, cutoff_time(7))

    assert_that(result, equal_to(Time(7, 15)))
Пример #6
0
def test_24_hour():
    time_text = "14:34"
    result = from_user_time(time_text, cutoff_time(7))

    assert_that(result, equal_to(Time(14, 34)))
Пример #7
0
def test_semicolon_separator():
    time_text = "4;15"
    result = from_user_time(time_text, cutoff_time(7))

    assert_that(result, equal_to(Time(16, 15)))
Пример #8
0
def test_dot_separator():
    time_text = "12.10"
    result = from_user_time(time_text, cutoff_time(7))

    assert_that(result, equal_to(Time(12, 10)))