Exemplo n.º 1
0
def test_validate_input_value_integer_out_of_bound(integer_space):
    """Test if out of bound values passed to integer space are rejected properly"""
    namespace = 'x'

    is_valid, casted_value = _validate_input_value("100.0", integer_space, namespace)
    assert not is_valid

    is_valid, casted_value = _validate_input_value("100", integer_space, namespace)
    assert not is_valid
Exemplo n.º 2
0
def test_validate_input_value_categorical_string_value(categorical_space):
    """Test if literal string value passed to categorical space is validated properly"""
    namespace = 'x'

    is_valid, casted_value = _validate_input_value("random", categorical_space, namespace)
    assert not is_valid

    is_valid, casted_value = _validate_input_value("string", categorical_space, namespace)
    assert is_valid
    assert isinstance(casted_value, str)
Exemplo n.º 3
0
def test_validate_input_value_categorical_integer_hit(categorical_space):
    """Test if integer value passed to categorical space is validated properly"""
    namespace = 'x'

    is_valid, casted_value = _validate_input_value("11", categorical_space, namespace)
    assert is_valid
    assert isinstance(casted_value, numbers.Number)

    is_valid, casted_value = _validate_input_value("11.0", categorical_space, namespace)
    assert is_valid
    assert isinstance(casted_value, numbers.Number)
Exemplo n.º 4
0
def test_validate_input_value_real_out_of_bound(real_space):
    """Test if out of bound values passed to real space are rejected properly"""
    namespace = '/x'

    is_valid, casted_value = _validate_input_value("100.0", real_space,
                                                   namespace)
    assert not is_valid

    is_valid, casted_value = _validate_input_value("100", real_space,
                                                   namespace)
    assert not is_valid
Exemplo n.º 5
0
def test_validate_input_value_categorical_string_number(categorical_space):
    """Test if string number value passed to categorical space is validated properly"""
    namespace = 'x'

    # Make sure integer 12 does not pass
    is_valid, casted_value = _validate_input_value("12", categorical_space, namespace)
    assert not is_valid

    # Now test "12" as a string
    is_valid, casted_value = _validate_input_value("'12'", categorical_space, namespace)
    assert is_valid
    assert isinstance(casted_value, str)
Exemplo n.º 6
0
def test_validate_input_value_categorical_real_nohit(categorical_space):
    """Test if bad real value passed to categorical space is rejected properly"""
    namespace = 'x'

    is_valid, casted_value = _validate_input_value("10", categorical_space, namespace)
    assert not is_valid

    is_valid, casted_value = _validate_input_value("10.0", categorical_space, namespace)
    assert not is_valid

    is_valid, casted_value = _validate_input_value("10.2", categorical_space, namespace)
    assert not is_valid
Exemplo n.º 7
0
def test_validate_input_value_integer_integer(integer_space):
    """Test if integer value passed to integer space is validated properly"""
    namespace = 'x'

    is_valid, casted_value = _validate_input_value("10", integer_space, namespace)
    assert is_valid
    assert isinstance(casted_value, numbers.Number)
Exemplo n.º 8
0
def test_validate_input_value_integer_string(integer_space):
    """Test if string value passed to integer space is rejected properly"""
    namespace = '/x'

    is_valid, casted_value = _validate_input_value("string", integer_space,
                                                   namespace)
    assert not is_valid
Exemplo n.º 9
0
def test_validate_input_value_real_real(real_space):
    """Test if real value passed to real space is validated properly"""
    namespace = '/x'
    is_valid, casted_value = _validate_input_value("10.0", real_space,
                                                   namespace)
    assert is_valid
    assert isinstance(casted_value, numbers.Number)
Exemplo n.º 10
0
def test_validate_input_value_categorical_integer_nohit(categorical_space):
    """Test if bad integer value passed to categorical space is rejected properly"""
    namespace = "x"

    is_valid, casted_value = _validate_input_value("15", categorical_space,
                                                   namespace)
    assert not is_valid
Exemplo n.º 11
0
def test_validate_input_value_categorical_real_hit(categorical_space):
    """Test if real value passed to categorical space is validated properly"""
    namespace = "x"

    is_valid, casted_value = _validate_input_value("10.1", categorical_space,
                                                   namespace)
    assert is_valid
    assert isinstance(casted_value, numbers.Number)
Exemplo n.º 12
0
def test_validate_input_value_real_string(real_space):
    """Test if string value passed to real space is rejected properly"""
    namespace = 'x'
    is_valid, casted_value = _validate_input_value("string", real_space, namespace)
    assert not is_valid
Exemplo n.º 13
0
def test_validate_input_value_real_integer(real_space):
    """Test if integer value passed to real space is validated properly"""
    namespace = "x"
    is_valid, casted_value = _validate_input_value("10", real_space, namespace)
    assert is_valid
    assert isinstance(casted_value, numbers.Number)