コード例 #1
0
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"]
コード例 #2
0
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"}
コード例 #3
0
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() == []