コード例 #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
コード例 #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)
コード例 #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)
コード例 #4
0
ファイル: test_insert.py プロジェクト: 5l1v3r1/orion-1
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
コード例 #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)
コード例 #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
コード例 #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)
コード例 #8
0
ファイル: test_insert.py プロジェクト: 5l1v3r1/orion-1
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
コード例 #9
0
ファイル: test_insert.py プロジェクト: 5l1v3r1/orion-1
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)
コード例 #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
コード例 #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)
コード例 #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
コード例 #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)