Esempio n. 1
0
def check_rule_creation_bool_pattern(request):
    selector = Selector()

    r = "unstable"
    selector.include(r)
    rule = selector.irules[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.include(r)
    rule = selector.irules[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'
Esempio n. 2
0
def check_rule_evaluation_prop_pattern(request):
    selector = Selector()
    r = "unstable is true"
    selector.include(r)
    rule = selector.irules[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 = "unstable is false"
    selector.include(r)
    rule = selector.irules[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
Esempio n. 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)
Esempio n. 4
0
def check_rule_creation_user_prop(request):
    r = "rating is 2"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "rating"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == "2"
    assert rule.checker.__name__ == 'are_equal'
Esempio n. 5
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)
Esempio n. 6
0
def check_rule_creation_invalid(request):
    try:
        selector = Selector()
        r = "unstable is anything"
        selector.include(r)
    except InvalidSelectionRule:
        pass
    else:
        assert 1 == 2

    try:
        selector = Selector()
        r = "unstable < True"
        selector.include(r)
    except InvalidSelectionRule:
        pass
    else:
        assert 1 == 2
Esempio n. 7
0
def check_third_include_match(request):
    obj = Obj()
    obj.info.unstable = True
    obj.info.priority = 2
    obj.tags = {'chrome'}

    selector = Selector()    
    selector.include("not unstable")
    selector.include("priority is 3")
    selector.include("with tag chrome")
    
    selector.validate(obj)
Esempio n. 8
0
def check_no_include_match(request):
    obj = Obj()
    obj.info.unstable = True
    obj.info.priority = 2
    obj.tags = {'chrome'}

    selector = Selector()    
    selector.include("not unstable")
    selector.include("priority is 3")
    selector.include("with tag firefox")
    
    try:
        selector.validate(obj)
    except NoInclusionRuleMet as e:
        pass
    else:
        raise AssertionError()
def check_rule_creation_str_prop_comp(request):
    r = "app_version is 2.1.1"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == "2.1.1"
    assert rule.checker.__name__ == 'are_equal'

    r = "app_version eq 2.1.1"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == "2.1.1"
    assert rule.checker.__name__ == 'are_equal'

    r = "app_version = 2.1.1"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == "2.1.1"
    assert rule.checker.__name__ == 'are_equal'

    r = "app_version == 2.1.1"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == "2.1.1"
    assert rule.checker.__name__ == 'are_equal'

    r = "app_version not 2.1.2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.NOT_EQUAL
    assert rule.expression == "2.1.2"
    assert rule.checker.__name__ == 'are_not_equal'

    r = "app_version != 2.1.2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.NOT_EQUAL
    assert rule.expression == "2.1.2"
    assert rule.checker.__name__ == 'are_not_equal'

    r = "app_version ne 2.1.2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.NOT_EQUAL
    assert rule.expression == "2.1.2"
    assert rule.checker.__name__ == 'are_not_equal'

    r = "app_version lt 2.1.2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.LESS_THAN
    assert rule.expression == "2.1.2"
    assert rule.checker.__name__ == 'less_than'

    r = "app_version < 2.1.2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.LESS_THAN
    assert rule.expression == "2.1.2"
    assert rule.checker.__name__ == 'less_than'

    r = "app_version gt 2.1.0"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.GREATER_THAN
    assert rule.expression == "2.1.0"
    assert rule.checker.__name__ == 'greater_than'

    r = "app_version > 2.1.0"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.GREATER_THAN
    assert rule.expression == "2.1.0"
    assert rule.checker.__name__ == 'greater_than'

    r = "app_version le 2.1.1"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.LESS_OR_EQUAL
    assert rule.expression == "2.1.1"
    assert rule.checker.__name__ == 'less_or_equal'

    r = "app_version <= 2.1.1"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.LESS_OR_EQUAL
    assert rule.expression == "2.1.1"
    assert rule.checker.__name__ == 'less_or_equal'

    r = "app_version ge 2.1.1"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.GREATER_OR_EQUAL
    assert rule.expression == "2.1.1"
    assert rule.checker.__name__ == 'greater_or_equal'

    r = "app_version >= 2.1.1"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "app_version"
    assert rule.condition == RuleConditionType.GREATER_OR_EQUAL
    assert rule.expression == "2.1.1"
    assert rule.checker.__name__ == 'greater_or_equal'
Esempio n. 10
0
def check_rule_creation_prop_pattern(request):
    # Check boolean prop
    selector = Selector()
    r = "unstable is False"
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "unstable"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == False
    assert rule.checker.__name__ == 'are_equal'

    selector = Selector()
    r = "unstable not True"
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    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'

    # Check boolean prop - value alternatives
    selector = Selector()
    r = "unstable is On"
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    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'

    selector = Selector()
    r = "unstable is oFf"
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "unstable"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == False
    assert rule.checker.__name__ == 'are_equal'

    # Check boolean prop - value alternatives
    selector = Selector()
    r = "unstable is YeS"
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    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'

    selector = Selector()
    r = "unstable is nO"
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "unstable"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == False
    assert rule.checker.__name__ == 'are_equal'
Esempio n. 11
0
def check_rule_creation_priority(request):
    r = "priority is 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == 2
    assert rule.checker.__name__ == 'are_equal'

    r = "priority eq 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == 2
    assert rule.checker.__name__ == 'are_equal'

    r = "priority = 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == 2
    assert rule.checker.__name__ == 'are_equal'

    r = "priority == 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == 2
    assert rule.checker.__name__ == 'are_equal'

    r = "priority not 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.NOT_EQUAL
    assert rule.expression == 2
    assert rule.checker.__name__ == 'are_not_equal'

    r = "priority != 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.NOT_EQUAL
    assert rule.expression == 2
    assert rule.checker.__name__ == 'are_not_equal'

    r = "priority ne 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.NOT_EQUAL
    assert rule.expression == 2
    assert rule.checker.__name__ == 'are_not_equal'

    r = "priority lt 3"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.GREATER_THAN
    assert rule.expression == 3
    assert rule.checker.__name__ == 'greater_than'

    r = "priority < 3"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.GREATER_THAN
    assert rule.expression == 3
    assert rule.checker.__name__ == 'greater_than'

    r = "priority gt 1"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.LESS_THAN
    assert rule.expression == 1
    assert rule.checker.__name__ == 'less_than'

    r = "priority > 1"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.LESS_THAN
    assert rule.expression == 1
    assert rule.checker.__name__ == 'less_than'

    r = "priority le 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.GREATER_OR_EQUAL
    assert rule.expression == 2
    assert rule.checker.__name__ == 'greater_or_equal'

    r = "priority <= 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.GREATER_OR_EQUAL
    assert rule.expression == 2
    assert rule.checker.__name__ == 'greater_or_equal'

    r = "priority ge 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.LESS_OR_EQUAL
    assert rule.expression == 2
    assert rule.checker.__name__ == 'less_or_equal'

    r = "priority >= 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "priority"
    assert rule.condition == RuleConditionType.LESS_OR_EQUAL
    assert rule.expression == 2
    assert rule.checker.__name__ == 'less_or_equal'
Esempio n. 12
0
def check_priority_selection(request):
    r = "priority is 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)

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

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

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

    r = "priority is 5"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)

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

    r = "priority not 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)

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

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

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

    r = "priority lt 3"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)

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

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

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

    r = "priority gt 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)

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

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

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

    r = "priority le 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)

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

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

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

    r = "priority ge 2"
    selector = Selector()    
    selector.include(r)
    rule = selector.irules[0]
    print(rule)

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

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

    obj = Obj()
    obj.info.priority = 3
    assert rule.matches(obj) is False
Esempio n. 13
0
def check_rule_creation_tags(request):
    r = "with tags chrome, firefox"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "tags"
    assert rule.target == set({'chrome', 'firefox'})
    assert rule.condition == RuleConditionType.HAS_INTERSECTION
    assert rule.expression == set({'chrome', 'firefox'})
    assert rule.checker.__name__ == 'has_intersection'

    r = "with tag chrome"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "tags"
    assert rule.target == set({'chrome'})
    assert rule.condition == RuleConditionType.HAS_INTERSECTION
    assert rule.expression == set({'chrome'})
    assert rule.checker.__name__ == 'has_intersection'

    r = "withall tags chrome, abc"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "tags"
    assert rule.target == set({'chrome', 'abc'})
    assert rule.condition == RuleConditionType.IS_SUBSET
    assert rule.expression == set({'chrome', 'abc'})
    assert rule.checker.__name__ == 'is_subset'

    r = "without tags chrome, abc"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "tags"
    assert rule.target == set({'chrome', 'abc'})
    assert rule.condition == RuleConditionType.NO_INTERSECTION
    assert rule.expression == set({'chrome', 'abc'})
    assert rule.checker.__name__ == 'has_no_intersection'

    r = "without tag chrome"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "tags"
    assert rule.target == set({'chrome'})
    assert rule.condition == RuleConditionType.NO_INTERSECTION
    assert rule.expression == set({'chrome'})
    assert rule.checker.__name__ == 'has_no_intersection'

    r = "with bugs b1,b2"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "bugs"
    assert rule.target == set({'b1', 'b2'})
    assert rule.condition == RuleConditionType.HAS_INTERSECTION
    assert rule.expression == set({'b1', 'b2'})
    assert rule.checker.__name__ == 'has_intersection'

    r = "with bug b1"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "bugs"
    assert rule.target == set({'b1'})
    assert rule.condition == RuleConditionType.HAS_INTERSECTION
    assert rule.expression == set({'b1'})
    assert rule.checker.__name__ == 'has_intersection'

    r = "withall bugs b1,abc"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "bugs"
    assert rule.target == set({'b1', 'abc'})
    assert rule.condition == RuleConditionType.IS_SUBSET
    assert rule.expression == set({'b1', 'abc'})
    assert rule.checker.__name__ == 'is_subset'

    r = "without bugs b1,abc"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "bugs"
    assert rule.target == set({'b1', 'abc'})
    assert rule.condition == RuleConditionType.NO_INTERSECTION
    assert rule.expression == set({'b1', 'abc'})
    assert rule.checker.__name__ == 'has_no_intersection'

    r = "without bug b1"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "bugs"
    assert rule.target == set({'b1'})
    assert rule.condition == RuleConditionType.NO_INTERSECTION
    assert rule.expression == set({'b1'})
    assert rule.checker.__name__ == 'has_no_intersection'

    r = "with envs env1, env2"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "envs"
    assert rule.target == set({'env1', 'env2'})
    assert rule.condition == RuleConditionType.HAS_INTERSECTION
    assert rule.expression == set({'env1', 'env2'})
    assert rule.checker.__name__ == 'has_intersection'

    r = "with env env1"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "envs"
    assert rule.target == set({'env1'})
    assert rule.condition == RuleConditionType.HAS_INTERSECTION
    assert rule.expression == set({'env1'})
    assert rule.checker.__name__ == 'has_intersection'

    r = "withall envs env1, env2"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "envs"
    assert rule.target == set({'env1', 'env2'})
    assert rule.condition == RuleConditionType.IS_SUBSET
    assert rule.expression == set({'env1', 'env2'})
    assert rule.checker.__name__ == 'is_subset'

    r = "without envs env1, env2"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "envs"
    assert rule.target == set({'env1', 'env2'})
    assert rule.condition == RuleConditionType.NO_INTERSECTION
    assert rule.expression == set({'env1', 'env2'})
    assert rule.checker.__name__ == 'has_no_intersection'

    r = "without env env1"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "IterablePatternRule"
    assert rule.rule_str == r
    assert rule.container == "envs"
    assert rule.target == set({'env1'})
    assert rule.condition == RuleConditionType.NO_INTERSECTION
    assert rule.expression == set({'env1'})
    assert rule.checker.__name__ == 'has_no_intersection'
Esempio n. 14
0
def get_rule(r):
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    return rule
Esempio n. 15
0
def check_rule_creation_str_prop_simple(request):

    r = "author is Rahul Verma"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "author"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == "Rahul Verma"
    assert rule.checker.__name__ == 'are_equal'

    r = "author eq Rahul Verma"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "author"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == "Rahul Verma"
    assert rule.checker.__name__ == 'are_equal'

    r = "author = Rahul Verma"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "author"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == "Rahul Verma"
    assert rule.checker.__name__ == 'are_equal'

    r = "author == Rahul Verma"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "author"
    assert rule.condition == RuleConditionType.EQUAL
    assert rule.expression == "Rahul Verma"
    assert rule.checker.__name__ == 'are_equal'

    r = "author != Rahul Verma"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "author"
    assert rule.condition == RuleConditionType.NOT_EQUAL
    assert rule.expression == "Rahul Verma"
    assert rule.checker.__name__ == 'are_not_equal'

    "author not Rahul Verma"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "author"
    assert rule.condition == RuleConditionType.NOT_EQUAL
    assert rule.expression == "Rahul Verma"
    assert rule.checker.__name__ == 'are_not_equal'

    "author ne Rahul Verma"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "author"
    assert rule.condition == RuleConditionType.NOT_EQUAL
    assert rule.expression == "Rahul Verma"
    assert rule.checker.__name__ == 'are_not_equal'

    r = "author matches Rahul VERMA"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "author"
    assert rule.condition == RuleConditionType.MATCHES
    assert rule.expression == "Rahul VERMA"
    assert rule.checker.__name__ == 'match_with_ignore_case'

    r = "author ~= Rahul VERMA"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "author"
    assert rule.condition == RuleConditionType.MATCHES
    assert rule.expression == "Rahul VERMA"
    assert rule.checker.__name__ == 'match_with_ignore_case'

    r = "author *= RaHuL"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)
    assert rule.__class__.__name__ == "AttrPatternRule"
    assert rule.rule_str == r
    assert rule.container == "info"
    assert rule.target == "author"
    assert rule.condition == RuleConditionType.PARTIALLY_MATCHES
    assert rule.expression == "RaHuL"
    assert rule.checker.__name__ == 'partially_match_with_ignore_case'
Esempio n. 16
0
def check_str_selection(request):
    r = "author is Rahul Verma"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)

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

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

    obj = Obj()
    obj.info.author = 'Rahul Verma'
    assert rule.matches(obj) is True

    obj = Obj()
    obj.info.author = 'rahul Verma'
    assert rule.matches(obj) is False

    r = "author != Rahul Verma"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)

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

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

    obj = Obj()
    obj.info.author = 'Rahul Verma'
    assert rule.matches(obj) is False

    obj = Obj()
    obj.info.author = 'rahul Verma'
    assert rule.matches(obj) is True

    r = "author ~= Rahul VERMA"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)

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

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

    obj = Obj()
    obj.info.author = 'rahul Verma'
    assert rule.matches(obj) is True

    obj = Obj()
    obj.info.author = 'Arjuna'
    assert rule.matches(obj) is False

    r = "author *= RaHuL"
    selector = Selector()
    selector.include(r)
    rule = selector.irules[0]
    print(rule)

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

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

    obj = Obj()
    obj.info.author = 'X RAHul Y'
    assert rule.matches(obj) is True

    obj = Obj()
    obj.info.author = 'Rah'
    assert rule.matches(obj) is False