Ejemplo n.º 1
0
def test_yaml_term_string_enum():
    yaml_input = """
    term_name_6:
        type: String
        enum: ['1', '2', '3', 'ok test']
    """
    YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 2
0
def test_yaml_term_alpha_enum():
    yaml_input = """
    term_name_6:
        type: Alpha
        enum: [logic1, my_logic, well]
    """
    YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 3
0
def test_yaml_term_string_invalid_enum():
    yaml_input = """
    term_name_6:
        type: String
        enum: [1, 'my logic', 'wow']
    """
    with pytest.raises(ValueError):
        YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 4
0
def test_yaml_term_alpha_invalid_enum():
    yaml_input = """
    term_name_6:
        type: Alpha
        enum: [logic1, 'my logic', well]
    """
    with pytest.raises(ValueError):
        YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 5
0
def test_yaml_term_pattern():
    for i in {'String', 'Alpha'}:
        yaml_input = """
        term_name_6:
            type: %s
            pattern: '(a | b)'
        """ % i
        YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 6
0
def test_yaml_term_integer_declaration_invalid_enum_integer():
    for i in [['1', 2, 3], 1, {'value': 0}]:
        yaml_input = """
        term_name_6:
            type: Integer
            enum: %s
        """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 7
0
def test_yaml_term_integer_declaration_invalid_max():
    for i in {1000000000000, 'Integer'}:
        yaml_input = """
        term_name_6:
            type: Integer
            max: %s        
        """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 8
0
def test_yaml_term_integer_min_greater_than_max():
    yaml_input = """
    term_name_6:
        type: Integer
        min: 20
        max: 10        
    """
    with pytest.raises(ValueError):
        YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 9
0
def test_yaml_term_invalid_term_types():
    for i in [
            'Name', 'Valasp', 'on', 'off', 1, -2, ['name'], '"1"', "_Predicate"
    ]:
        yaml_input = """
        term1: %s
        """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 10
0
def test_yaml_term_invalid_pattern():
    for i in {'String', 'Alpha'}:
        yaml_input = """
        term_name_6:
            type: %s
            pattern: '(a | b'
        """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 11
0
def test_yaml_term_type_declaration():
    for i in {
            'Integer', 'String', 'Alpha', 'Any', 'predicate', '_predicate',
            '_preDicate', '___predicate', '"on"', '"off"'
    }:
        yaml_input = """
        term1: %s
        """ % i
        YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 12
0
def test_yaml_term_integer_declaration_wrong_keyword():
    for j in {'Integer', 'String'}:
        for i in {'MIN', 'minimum'}:
            yaml_input = """
            term_name_6:
                type: %s
                %s: 0
            """ % (j, i)
            with pytest.raises(ValueError):
                YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 13
0
def test_yaml_term_alpha_invalid_min():
    for s in {'String', 'Alpha'}:
        for i in [-1, 'a', [1, 2]]:
            yaml_input = """
            term_name_6:
                type: %s
                min: %s
            """ % (s, i)
            with pytest.raises(ValueError):
                YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 14
0
def test_yaml_term_integer_declaration_invalid_min():
    for j in {'Integer', 'String'}:
        for i in {1000000000000, 'Integer'}:
            yaml_input = """
            term_name_6:
                type: %s
                min: %s        
            """ % (j, i)
            with pytest.raises(ValueError):
                YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 15
0
def test_yaml_term_elements_invalid_declaration():
    for j in {'String', 'Any', 'Alpha', 'user_defined'}:
        for i in {'sum+', 'sum-'}:
            yaml_input = """
            term_name_6:
                type: %s
                %s:
                    min: 0
                    max: 1000
            """ % (j, i)
            with pytest.raises(ValueError):
                YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 16
0
def test_yaml_valasp_in_user_defined_module():
    yaml_input = """
    valasp:
        having:
            - first == second
            - first2 != second
            - first3 < second
            - first3 <= second
            - first3 > second
            - first3 >= second
            - first    ==     second
            - first==second   
            - first  >=second
            - first>=second        
        validate_predicate: True        
    """
    YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 17
0
def test_yaml_term_integer_declaration():
    yaml_input = """
    term_name_6:
        type: Integer
        min: 0
        max: 99
        sum+:
            min: 0
            max: 1000
        sum-:
            min: -1000
            max: -10
        count:
            min: 10
            max: 100
        sum+: Integer
        enum: [1, 2, 3]
    """
    YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 18
0
def test_yaml_term_integer_declaration_no_type():
    yaml_input = """
    term_name_6:
        min: 0
        max: 99
        sum+:
            min: 0
            max: 1000
        sum-:
            min: 0
            max: -1000
        count:
            min: 10
            max: 100
        sum+: Integer
        enum: [1, 2, 3]
    """
    with pytest.raises(ValueError):
        YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 19
0
def test_yaml_term_integer_declaration_invalid_sum_negative():
    for i in {'String', 'int', -10}:
        yaml_input = """
        term_name_6:
            type: Integer
            sum-: %s                 
        """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_symbol(yaml.safe_load(yaml_input))

    for i in {-10000000000, 'Integer', 10}:
        yaml_input = """
        term_name_6:
            type: Integer
            sum-:
                min: 0
                max: %s  
        """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_symbol(yaml.safe_load(yaml_input))

    for i in {-10000000000, 'Integer', 10}:
        yaml_input = """
        term_name_6:
            type: Integer
            sum-:
                min: %s
                max: 0  
        """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_symbol(yaml.safe_load(yaml_input))
Ejemplo n.º 20
0
def test_yaml_term_declaration_invalid_count():
    for j in {'Integer', 'String', 'Any', 'Alpha', 'user_defined'}:
        for i in {-5, 100000000000, 'Integer'}:
            yaml_input = """
            term_name_6:
                type: %s
                count:
                    min: %s
                    max: 0  
            """ % (j, i)
            with pytest.raises(ValueError):
                YamlValidation.validate_symbol(yaml.safe_load(yaml_input))

        for i in {-5, 100000000000, 'Integer'}:
            yaml_input = """
            term_name_6:
                type: %s
                count:
                    min: 0
                    max: %s  
            """ % (j, i)
            with pytest.raises(ValueError):
                YamlValidation.validate_symbol(yaml.safe_load(yaml_input))