def test_parse_query__absolute_time__error(query, message): with pytest.raises(ParseQueryError, match=message): value = parse_query(f'{query} hello') assert 0, f"unexpected value: {value!r}"
def test_parse_query__5m_hello_world__correct_result_returned(): assert parse_query('5m hello world') == (5 * 60, '5m', 'hello world')
def test_parse_query__absolute_time__correct_result_returned(query, result): assert parse_query(f'{query} hello') == (result, query, 'hello')
def test_parse_query__incorrect_query__ParseQueryError(): with pytest.raises(ParseQueryError): assert parse_query('wfa')
def test_parse_query__incorrect_query_with_no_units__ParseQueryError(): with pytest.raises(ParseQueryError): assert parse_query('1h3')
def test_pasrse_query__is_case_insensitive(): assert parse_query('1H2M3S') == (1 * 60 * 60 + 2 * 60 + 3, '1H2M3S', 'Time is up!')
def test_parse_query__2m_5s__is_correct_query(): assert parse_query('2m5s') == (2 * 60 + 5, '2m5s', 'Time is up!')
def test_parse_query__1h_2s_hello__correct_result_returned(): assert parse_query('1h2s hello') == (1 * 60 * 60 + 2, '1h2s', 'hello')
def test_parse_query__5h_37m_hello__correct_result_returned(): assert parse_query('5h37m hello') == (5 * 60 * 60 + 37 * 60, '5h37m', 'hello')
def test_parse_query__5__is_correct_query(): assert parse_query('5') == (5 * 60, '5', 'Time is up!')