Example #1
0
def check_evaluation_exclude_rule(request):
    selector = Selector()
    r = "unstable"
    selector.exclude(r)
    rule = selector.erules[0]
    print(rule)

    obj = Obj()
    assert rule.matches(obj) is False

    obj = Obj()
    obj.info.unstable = True
    assert rule.matches(obj) is True

    obj = Obj()
    obj.info.unstable = False
    assert rule.matches(obj) is False

    selector = Selector()
    r = "not unstable"
    selector.exclude(r)
    rule = selector.erules[0]
    print(rule)

    obj = Obj()
    assert rule.matches(obj) is True

    obj = Obj()
    obj.info.unstable = True
    assert rule.matches(obj) is False

    obj = Obj()
    obj.info.unstable = False
    assert rule.matches(obj) is True
Example #2
0
def check_creation_exclude_rule(request):
    selector = Selector()

    r = "unstable"
    selector.exclude(r)
    rule = selector.erules[0]
    print(rule)
    assert rule.__class__.__name__ == "BoolAttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "unstable"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == True
    assert rule.checker.__name__ == 'are_equal'

    # Check NOT
    selector = Selector()
    r = "not unstable"
    selector.exclude(r)
    rule = selector.erules[0]
    print(rule)
    assert rule.__class__.__name__ == "BoolAttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "unstable"
    assert rule.condition == RuleConditionType.NOT_EQUAL
    assert rule.expression == True
    assert rule.checker.__name__ == 'are_not_equal'
Example #3
0
    def __load_tests(self, *, rules):
        from arjuna import Arjuna
        from arjuna.engine.selection.selector import Selector
        selector = Selector()
        if rules:
            for rule in rules['ir']:
                selector.include(rule)
            for rule in rules['er']:
                selector.exclude(rule)

        Arjuna.register_test_selector_for_group(selector)
Example #4
0
    def _load_tests(self, rule_dict):
        i_e_rules = self.__create_rule_strs(rule_dict)
        rules = {'ir': [], 'er': []}
        rules['ir'].extend(i_e_rules['ir'])
        rules['er'].extend(i_e_rules['er'])

        from arjuna.engine.selection.selector import Selector
        selector = Selector()
        if rules:
            for rule in rules['ir']:
                selector.include(rule)
            for rule in rules['er']:
                selector.exclude(rule)

        from arjuna import Arjuna
        Arjuna.register_test_selector_for_group(selector)
Example #5
0
def check_no_exclude_match(request):
    obj = Obj()
    obj.info.unstable = True
    obj.info.priority = 2
    obj.tags = {'chrome'}

    selector = Selector()    
    selector.exclude("not unstable")
    selector.exclude("priority is 3")
    selector.exclude("with tag firefox")
    
    selector.validate(obj)
Example #6
0
def check_third_exclude_match(request):
    obj = Obj()
    obj.info.unstable = True
    obj.info.priority = 2
    obj.tags = {'chrome'}

    selector = Selector()    
    selector.exclude("not unstable")
    selector.exclude("priority is 3")
    selector.exclude("with tag chrome")
    
    try:
        selector.validate(obj)
    except ExclusionRuleMet as e:
        assert e.rule.rule_str == "with tag chrome"
    else:
        raise AssertionError()