Example #1
0
def test_boolean_basic_validation():
    b = types.BooleanType()

    b.validate(True)
    b.validate(False)

    with pytest.raises(exceptions.ValidationException):
        b.validate(types.Unset)
Example #2
0
def test_boolean_strict_validation():
    b = types.BooleanType(strict=True)

    b.validate(True)
    b.validate(False)

    with pytest.raises(exceptions.ValidationException):
        b.validate('true')

    with pytest.raises(exceptions.ValidationException):
        b.validate('false')
Example #3
0
def test_boolean_string_validation():
    b = types.BooleanType()

    b.validate('true')
    b.validate('false')
Example #4
0
def test_boolean_instance_config_default():
    b = types.BooleanType(default=True)

    assert b.to_native(types.Unset) == True
    assert b.to_native(False) == False
Example #5
0
 class TestType(types.Type):
     s = types.StringType()
     b = types.BooleanType()
Example #6
0
 class TestType(types.Type):
     st = types.SumType(types.StringType(min_length=10),
                        types.BooleanType())
     b = types.BooleanType()