Exemplo n.º 1
0
def test_call_invalid_type():
    op = get_operator(MatchOperatorType.MATCHES, str, [r'/post'])
    with pytest.raises(MatchOperatorError) as exc_info:
        op(123)
    assert str(exc_info.value) == (
        'Match operator[matches] error: Can not evaluate matching operator, '
        "unsupported value type: <class 'int'>.")
Exemplo n.º 2
0
def _test_operator(op_type, params, value, result):
    op = get_operator(op_type, type(value), params)
    assert op(value) is result
Exemplo n.º 3
0
def test_none_is_false():
    op = get_operator(MatchOperatorType.MATCHES, str, [r'/post'])
    assert op(None) is False
Exemplo n.º 4
0
def test_build_invalid_type():
    with pytest.raises(MatchOperatorError) as exc_info:
        get_operator(MatchOperatorType.MATCHES, int, [r'/post'])
    assert str(exc_info.value) == (
        'Match operator[matches] error: Can not build matching operator, '
        "unsupported value type: <class 'int'>.")