def test_Condition(self): rule = Rule("declarationFactory") decl = rule.addParameterDeclaration("r", drools.ObjectType(Record)) cond = drools.Condition([decl], lambda r: r.n > 4) self.failUnless(cond.isAllowed(MockTuple(Record(5)))) cond = drools.Condition([decl], lambda r: r.n > 4) self.failIf(cond.isAllowed(MockTuple(Record(4))))
def test_Consequence(self): rule = Rule("declarationFactory") decl = rule.addParameterDeclaration("r", drools.ObjectType(Record)) r = Record() def fn(mem, r): r.n = 5 cons = drools.Consequence([decl], fn) cons.invoke(MockTuple(r)) self.assertEquals(r.n, 5)