Example #1
0
def test_required():
    with pytest.raises(ValidationError):
        ListInput(required=True).clean(json.dumps([]))
Example #2
0
def test_prepare_value():
    field = ListInput()
    prepare_value = field.prepare_value(["One", "Two", "Three"])
    assert prepare_value == '["One", "Two", "Three"]'
Example #3
0
def test_no_maximum_does_not_raise():
    ListInput(maximum=0).clean(json.dumps(["One" for i in range(200)]))
Example #4
0
def test_above_maximum_raises():
    with pytest.raises(ValidationError):
        ListInput(maximum=1).clean(json.dumps(["One", "Two", "Three"]))
Example #5
0
def test_no_minimum_does_not_raise():
    ListInput(minimum=0, required=False).clean(json.dumps([]))
Example #6
0
def test_below_minimum_raises():
    with pytest.raises(ValidationError):
        ListInput(minimum=1).clean(json.dumps([]))
Example #7
0
def test_to_python():
    field = ListInput()
    python_value = field.to_python('["One", "Two", "Three"]')
    assert python_value == ["One", "Two", "Three"]