Fixed EvalEvaluator when there is nothing to evaluate

This commit is contained in:
2019-12-27 14:43:36 +01:00
parent 21da87393f
commit 81b2355633
5 changed files with 97 additions and 15 deletions
+24 -3
View File
@@ -49,11 +49,32 @@ def test_i_can_match_and_eval():
@pytest.mark.parametrize("return_values, expected", [
([r(Concept("foo", body="bar")), eval_requested], True),
([r(Concept("status is false", body="bar"), False), eval_requested], False),
([r("string_value"), eval_requested], False),
([r(Concept("no body")), eval_requested], False),
([r(Concept("status is false", body="bar"), False), eval_requested], True),
([r("string_value"), eval_requested], True),
([r(Concept("no body")), eval_requested], True),
([r(Concept("eval requested missing", body="bar"))], False),
])
def test_i_cannot_match_if_eval_request_is_not_present(return_values, expected):
context = get_context()
assert EvalEvaluator().matches(context, return_values) == expected
def test_concept_eval_requested_is_reduced_when_nothing_to_reduce():
context = get_context()
return_values = [
ReturnValueConcept("some_name", True, "not to eval"),
ReturnValueConcept("some_name", True, Concept(name="not to eval")),
ReturnValueConcept("some_name", False, Concept(name="1", body="not to eval")),
eval_requested
]
evaluator = EvalEvaluator()
assert evaluator.matches(context, return_values)
evaluated = evaluator.eval(context, return_values)
assert evaluated == ReturnValueConcept(
"evaluators.Eval",
False,
context.sheerka.new(BuiltinConcepts.CONCEPT_EVAL_REQUESTED))
assert evaluated.parents == [eval_requested]