예제 #1
0
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}"
예제 #2
0
def test_parse_query__5m_hello_world__correct_result_returned():
    assert parse_query('5m hello world') == (5 * 60, '5m', 'hello world')
예제 #3
0
def test_parse_query__absolute_time__correct_result_returned(query, result):
    assert parse_query(f'{query} hello') == (result, query, 'hello')
예제 #4
0
def test_parse_query__incorrect_query__ParseQueryError():
    with pytest.raises(ParseQueryError):
        assert parse_query('wfa')
예제 #5
0
def test_parse_query__incorrect_query_with_no_units__ParseQueryError():
    with pytest.raises(ParseQueryError):
        assert parse_query('1h3')
예제 #6
0
def test_pasrse_query__is_case_insensitive():
    assert parse_query('1H2M3S') == (1 * 60 * 60 + 2 * 60 + 3, '1H2M3S', 'Time is up!')
예제 #7
0
def test_parse_query__2m_5s__is_correct_query():
    assert parse_query('2m5s') == (2 * 60 + 5, '2m5s', 'Time is up!')
예제 #8
0
def test_parse_query__1h_2s_hello__correct_result_returned():
    assert parse_query('1h2s hello') == (1 * 60 * 60 + 2, '1h2s', 'hello')
예제 #9
0
def test_parse_query__5h_37m_hello__correct_result_returned():
    assert parse_query('5h37m hello') == (5 * 60 * 60 + 37 * 60, '5h37m', 'hello')
예제 #10
0
def test_parse_query__5__is_correct_query():
    assert parse_query('5') == (5 * 60, '5', 'Time is up!')