コード例 #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!')