def test_configuration_with_fact_using_function(): facts = {"f1": "len(vals) == 10"} rules = {"r1": {"expression": "f1", "actions": ["launch"]}} le = LogicEngine({"rules": rules, "facts": facts, "channel_name": "test"}) assert le.produces() == ["actions", "newfacts"] assert le.consumes() == ["vals"]
def test_configuration_with_numy_facts(): facts = {"f1": "vals.sum() > blob.available"} rules = {"r1": {"expression": "f1", "actions": ["launch"]}} le = LogicEngine({"rules": rules, "facts": facts, "channel_name": "test"}) assert le.produces() == ["actions", "newfacts"] assert set(le.consumes()) == {"vals", "blob"}
def test_trivial_configuration(): """Logic engine constructed with trivial rules and facts.""" cfg = {"rules": {}, "facts": {}, "channel_name": "test"} le = LogicEngine(cfg) assert le.produces() == ["actions", "newfacts"] assert le.consumes() == []