Implemented a first and basic version of a Rete rule engine

This commit is contained in:
2021-02-09 16:06:32 +01:00
parent 821dbed189
commit a2a8d5c5e5
110 changed files with 7301 additions and 1654 deletions
@@ -0,0 +1,25 @@
from core.builtin_concepts_ids import BuiltinConcepts
from evaluators.PythonEvaluator import PythonEvalError
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
class TestSheerkaNonRegDisplay(TestUsingMemoryBasedSheerka):
def test_i_can_apply_simple_rule(self):
init = [
"def concept one as 1",
"when __ret.status then test_error()",
]
sheerka = self.init_scenario(init)
sheerka.enable_process_rules = True
res = sheerka.evaluate_user_input("one")
assert len(res) == 1
ret = res[0]
assert not ret.status
assert sheerka.isinstance(ret.body, BuiltinConcepts.ERROR)
assert isinstance(ret.body.body, PythonEvalError)
assert isinstance(ret.body.body.error, Exception)
assert ret.body.body.error.args == ("I can raise an error",)