Beispiel #1
0
def test_default():
    assert props.Number(default=123).load(None) == 123
Beispiel #2
0
def test_loads_int_from_string():
    assert props.Number().load("5") == 5
Beispiel #3
0
def test_wrong_type():
    with pytest.raises(props.PropertyValidationError):
        props.Number().load("nope")
Beispiel #4
0
def test_validate():
    props.Number().load(5)
Beispiel #5
0
def test_nullable():
    props.Number(nullable=True).load(None)
Beispiel #6
0
def test_not_nullable():
    with pytest.raises(props.PropertyValidationError):
        props.Number().load(None)
Beispiel #7
0
def test_too_high():
    with pytest.raises(props.PropertyValidationError):
        props.Number(max_value=10).load(20)
Beispiel #8
0
def test_too_low():
    with pytest.raises(props.PropertyValidationError):
        props.Number(min_value=10).load(5)
Beispiel #9
0
def test_accepts_float():
    assert props.Number().load(5.5) == 5.5
Beispiel #10
0
def test_accepts_int():
    assert props.Number().load(5) == 5
Beispiel #11
0
def test_not_allow_strings():
    with pytest.raises(props.PropertyValidationError):
        assert props.Number(allow_strings=False).load("5") == 5