def test_invalid_exclude_on(self): with pytest.raises(Exception) as exc_info: AndRules([ Rule(create_op_constraint('feat2', OpConstraint.OPS['ISSET'], None, 'anytype1', Constraint.VALUE_TYPE['RAW'])) ], '') assert 'exclude_on parameter of Rules must be either None or a list of strings' == str(exc_info.value) with pytest.raises(Exception) as exc_info: # Has to contain at least type AND feature AndRules([ Rule(create_op_constraint('feat2', OpConstraint.OPS['ISSET'], None, 'anytype1', Constraint.VALUE_TYPE['RAW'])) ], [ 'foo' ]) assert 'Invalid typeFeature selector "foo" found in excludeOn constraints in given Rules' == str(exc_info.value) with pytest.raises(Exception) as exc_info: # Has to contain at least type AND feature AndRules([ Rule(create_op_constraint('feat2', OpConstraint.OPS['ISSET'], None, 'anytype1', Constraint.VALUE_TYPE['RAW'])) ], [ 'notdefault.my-talent.output-feature' ]) assert 'Invalid typeFeature selector "notdefault.my-talent.output-feature". Has to be default type' == str(exc_info.value) with pytest.raises(Exception) as exc_info: # Has to contain at least type AND feature AndRules([ Rule(create_op_constraint('feat2', OpConstraint.OPS['ISSET'], None, 'anytype1', Constraint.VALUE_TYPE['RAW'])) ], [ 'default.*.feature' ]) assert 'Talent id has to be defined in typeFeature selector "default.*.feature"' == str(exc_info.value)
def test_append_single_rule(self): r = AndRules( Rule( create_op_constraint('feat2', OpConstraint.OPS['ISSET'], None, 'anytype1', Constraint.VALUE_TYPE['RAW']))) assert len(r.rules) == 1
def get_rules(self): if is_triggerable: return AndRules([ Rule( create_change_constraint('temp', 'kuehlschrank', Constraint.VALUE_TYPE['RAW'])) ]) return None
def rules(): opc1 = create_op_constraint('feat2', OpConstraint.OPS['GREATER_THAN'], 10, 'anytype1', Constraint.VALUE_TYPE['ENCODED'], '/foo', Constraint.ALL_INSTANCE_IDS_FILTER, True) opc2 = create_op_constraint('*', OpConstraint.OPS['ISSET'], None, 'anytype2', Constraint.VALUE_TYPE['RAW'], Constraint.PATH_IDENTITY, '^test$', False) rules = AndRules([ Rule(create_change_constraint('feat1', 'anytype1', Constraint.VALUE_TYPE['RAW'])), OrRules([ Rule(opc1), Rule(opc2) ]) ], [ 'anytype.feat3' ]) yield rules