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))
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
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
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)))
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)))
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)))
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)))
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)))