예제 #1
0
def test_config_int():
    int_inst = resolve_to_config_type(Int)
    assert not validate_config(int_inst, 1)
    assert validate_config(int_inst, None)
    assert validate_config(int_inst, 'r')

    assert not int_inst.is_list
    assert not int_inst.is_nullable
    assert not (int_inst.is_nullable or int_inst.is_list)
예제 #2
0
def test_list_int():
    list_int = resolve_to_config_type(List(Int))
    assert not validate_config(list_int, [1])
    assert not validate_config(list_int, [1, 2])
    assert not validate_config(list_int, [])
    assert validate_config(list_int, [None])
    assert validate_config(list_int, [1, None])
    assert validate_config(list_int, None)
    assert validate_config(list_int, [1, 'absdf'])
예제 #3
0
def test_list_nullable_int():
    lni = resolve_to_config_type(List(Nullable(Int)))
    assert not validate_config(lni, [1])
    assert not validate_config(lni, [1, 2])
    assert not validate_config(lni, [])
    assert not validate_config(lni, [None])
    assert not validate_config(lni, [1, None])
    assert validate_config(lni, None)
    assert validate_config(lni, [1, 'absdf'])
예제 #4
0
def test_nullable_int():
    nullable_int_inst = resolve_to_config_type(Nullable(Int))
    assert not validate_config(nullable_int_inst, 1)
    assert not validate_config(nullable_int_inst, None)
    assert validate_config(nullable_int_inst, 'r')
예제 #5
0
def test_config_enum_error():
    errors = list(validate_config(define_test_enum_type(), 'NOT_PRESENT'))
    assert len(errors) == 1
예제 #6
0
def test_config_enum_error_wrong_type():
    errors = list(validate_config(define_test_enum_type(), 384934))
    assert len(errors) == 1
예제 #7
0
def test_config_enum_error_none():
    errors = list(validate_config(define_test_enum_type(), None))
    assert len(errors) == 1
예제 #8
0
def test_config_enums():
    assert not list(validate_config(define_test_enum_type(), 'VALUE_ONE'))