Example #1
0
def test_yaml_having_valasp_in_user_defined_module_not_a_list():
    yaml_input = """
        having:            
            different: Integer                
        """
    with pytest.raises(ValueError):
        YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))
Example #2
0
def test_yaml_valasp_not_predicate():
    yaml_input = """    
    wrap:
        - a a        
    """
    with pytest.raises(ValueError):
        YamlValidation.validate_valasp(yaml.safe_load(yaml_input))
Example #3
0
def test_yaml_invalid_root():
    for i in ['Integer', 'VALASP', 10, ['a', 'b']]:
        yaml_input = """
                %s
                """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate(yaml.safe_load(yaml_input))
Example #4
0
def test_yaml_symbol_name_not_a_dictionary():
    for i in ['Integer', 'String', 'pred', ['a', 'b']]:
        yaml_input = """
        predicate: %s             
        """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate(yaml.safe_load(yaml_input))
Example #5
0
def test_yaml_valasp_max_arity_wrong_types():
    for i in ['a', -1, 100, {'a': 1}, [1]]:
        yaml_input = """
        max_arity: %s
        """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_valasp(yaml.safe_load(yaml_input))
Example #6
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))
Example #7
0
def test_yaml_valasp_wrap_not_list():
    for i in ['a', 1, {'a': 1}]:
        yaml_input = """    
        wrap: %s            
        """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_valasp(yaml.safe_load(yaml_input))
Example #8
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))
Example #9
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))
Example #10
0
def test_yaml_having_valasp_not_a_list():
    for i in [10, '1', {'first': 0}]:
        yaml_input = """
            having: %s              
            """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_valasp_in_symbol(
                yaml.safe_load(yaml_input))
Example #11
0
def test_yaml_validate_predicate_mispelled_true():
    for i in {'TRue', 'TrUE', 'TruE', 'trUe', 'truE'}:
        yaml_input = """
            validate_predicate: %s
            """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_valasp_in_symbol(
                yaml.safe_load(yaml_input))
Example #12
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))
Example #13
0
def test_yaml_auto_blacklist_mispelled_false():
    for i in {'falSe', 'FAlse', 'FaLSE', 'FalsE', 'falsE'}:
        yaml_input = """
            validate_predicate: %s
            """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_valasp_in_symbol(
                yaml.safe_load(yaml_input))
Example #14
0
def test_yaml_auto_blacklist_not_bool():
    for i in [0, 1, {'dict': 0}]:
        yaml_input = """
            auto_blacklist: %s
            """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_valasp_in_symbol(
                yaml.safe_load(yaml_input))
Example #15
0
def test_yaml_with_fun_wrong_keyword():
    for i in {'FORWARDIMPLICIT', 'WOW', 'forward', 'Implicit', '_TUPLE'}:
        yaml_input = """
            with_fun: %s
            """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_valasp_in_symbol(
                yaml.safe_load(yaml_input))
Example #16
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))
Example #17
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))
Example #18
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))
Example #19
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))
Example #20
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))
Example #21
0
def test_yaml_having_valasp_in_user_defined_module_not_valid_split():
    for i in ['first == second == third', ['a', 'b'], 'first of == second']:
        yaml_input = """
            having:
                - %s
            """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_valasp_in_symbol(
                yaml.safe_load(yaml_input))
Example #22
0
def test_yaml_having_valasp_in_user_defined_module_wrong_keyword():
    for i in {'different', '<>', '=', '>>'}:
        yaml_input = """
            having:
                - first %s second            
            """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_valasp_in_symbol(
                yaml.safe_load(yaml_input))
Example #23
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))
Example #24
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))
Example #25
0
def test_yaml_valasp_wrong_keyword():
    yaml_input = """
    python: |+
        for i in range(10):
            print(i)
    ASP: |+
        code
    """
    with pytest.raises(ValueError):
        YamlValidation.validate_valasp(yaml.safe_load(yaml_input))
Example #26
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))
Example #27
0
def test_yaml_valasp_python_wrong_type():
    yaml_input = """
    python:
        - something
        - here
    asp: |+
        a(X) :- b(X).
    """
    with pytest.raises(ValueError):
        YamlValidation.validate_valasp(yaml.safe_load(yaml_input))
Example #28
0
def test_yaml_symbol_name():
    for i in {
            'predicate', '_predicate', '_preDicate', '___predicate', '"on"',
            '"off"'
    }:
        yaml_input = """
        %s:
            term1: Integer
        """ % i
        YamlValidation.validate(yaml.safe_load(yaml_input))
Example #29
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))
Example #30
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))