Exemplo n.º 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))
Exemplo n.º 2
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))
Exemplo n.º 3
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))
Exemplo n.º 4
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))
Exemplo n.º 5
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))
Exemplo n.º 6
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))
Exemplo n.º 7
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))
Exemplo n.º 8
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))
Exemplo n.º 9
0
def test_yaml_having_valasp_in_user_defined_module_missing_list():
    yaml_input = """
        having:
            equals:                
            different:
                - [first, second]
                - [first2, second]
        """
    with pytest.raises(ValueError):
        YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))
Exemplo n.º 10
0
def test_yaml_having_valasp_in_user_defined_module_wrong_name():
    for i in {'>', '==', '!=', '<='}:
        yaml_input = """
            having:
                - First %s second       
            """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_valasp_in_symbol(
                yaml.safe_load(yaml_input))

    for i in {'>', '==', '!=', '<='}:
        yaml_input = """
            having:
                - first %s Second       
            """ % i
        with pytest.raises(ValueError):
            YamlValidation.validate_valasp_in_symbol(
                yaml.safe_load(yaml_input))
Exemplo n.º 11
0
def test_yaml_valasp_in_user_defined_module():
    yaml_input = """
    having:
        equals:
            - [first, second]
            - [first2, second]
        different:
            - [first, second]
            - [first2, second]
        gt:
            - [first, second]
            - [first2, second]
        ge:
            - [first, second]
            - [first2, second]
        lt:
            - [first, second]
            - [first2, second]
        le:
            - [first, second]
            - [first2, second]
    validate_predicate: True
    with_fun: FORWARD_IMPLICIT
    auto_blacklist: True
    after_init: |+
        code
        to
        add
        at
        the
        end
        of
        __post_init__
    before_grounding: |+
        cls.instances = set()
    after_grounding: |+
        if len(cls.instances()) < 10:
            raise ...
    """
    YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))
Exemplo n.º 12
0
def test_yaml_with_fun_correct():
    for i in {'FORWARD_IMPLICIT', 'FORWARD', 'IMPLICIT', 'TUPLE'}:
        yaml_input = """
            with_fun: %s
            """ % i
        YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))
Exemplo n.º 13
0
def test_yaml_after_grounding_wrong_type():
    yaml_input = """
    after_grounding: [1,2,3]       
    """
    with pytest.raises(ValueError):
        YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))
Exemplo n.º 14
0
def test_yaml_after_grounding():
    yaml_input = """
    after_grounding: |+
        code to execute after grounding
    """
    YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))
Exemplo n.º 15
0
def test_yaml_after_init():
    yaml_input = """
    after_init: |+
        code to add at the end of __post_init__
    """
    YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))
Exemplo n.º 16
0
def test_yaml_validate_predicate_correct_bool():
    for i in {'True', 'true', 'TRUE'}:
        yaml_input = """
            validate_predicate: %s
            """ % i
        YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))
Exemplo n.º 17
0
def test_yaml_auto_blacklist_correct_bool():
    for i in {'False', 'false', 'FALSE'}:
        yaml_input = """
            auto_blacklist: %s
            """ % i
        YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))