EvalEvaluator is called only if in root context. Added action and action_context to ExecutionContext
This commit is contained in:
@@ -7,11 +7,11 @@ from sdp.sheerkaDataProvider import Event
|
||||
|
||||
|
||||
def test_id_is_incremented_by_event_digest():
|
||||
a = ExecutionContext("foo", Event("event_1"), None)
|
||||
b = ExecutionContext("foo", Event("event_1"), None)
|
||||
c = ExecutionContext("foo", Event("event_2"), None)
|
||||
d = b.push()
|
||||
e = c.push()
|
||||
a = ExecutionContext("foo", Event("event_1"), None, BuiltinConcepts.NOP, None)
|
||||
b = ExecutionContext("foo", Event("event_1"), None, BuiltinConcepts.NOP, None)
|
||||
c = ExecutionContext("foo", Event("event_2"), None, BuiltinConcepts.NOP, None)
|
||||
d = b.push(BuiltinConcepts.NOP, None)
|
||||
e = c.push(BuiltinConcepts.NOP, None)
|
||||
|
||||
assert a.id == 0
|
||||
assert b.id == 1
|
||||
@@ -21,13 +21,14 @@ def test_id_is_incremented_by_event_digest():
|
||||
|
||||
|
||||
def test_i_can_use_with_statement():
|
||||
with ExecutionContext("who_", Event("event"), "fake_sheerka") as e:
|
||||
with ExecutionContext("who_", Event("event"), "fake_sheerka", BuiltinConcepts.NOP, None) as e:
|
||||
pass
|
||||
assert e.elapsed > 0
|
||||
|
||||
|
||||
def test_i_can_push():
|
||||
a = ExecutionContext("foo", Event("event_1"), "fake_sheerka", "some description",
|
||||
a = ExecutionContext("foo", Event("event_1"), "fake_sheerka", BuiltinConcepts.NOP, None,
|
||||
desc="some description",
|
||||
obj=Concept("foo"),
|
||||
step=BuiltinConcepts.EVALUATION,
|
||||
iteration=15,
|
||||
@@ -37,13 +38,15 @@ def test_i_can_push():
|
||||
a.local_hints.add(BuiltinConcepts.EVAL_BODY_REQUESTED)
|
||||
a.global_hints.add(BuiltinConcepts.EVAL_BODY_REQUESTED)
|
||||
|
||||
b = a.push()
|
||||
b = a.push(BuiltinConcepts.EVALUATION, "sub action context", desc="sub description")
|
||||
|
||||
assert b._parent == a
|
||||
assert b.who == a.who
|
||||
assert b.event == a.event
|
||||
assert b.sheerka == a.sheerka
|
||||
assert b.desc is None
|
||||
assert b.action == BuiltinConcepts.EVALUATION
|
||||
assert b.action_context == "sub action context"
|
||||
assert b.desc == "sub description"
|
||||
assert b.obj == a.obj
|
||||
assert b.step == a.step
|
||||
assert b.iteration == a.iteration
|
||||
@@ -56,10 +59,10 @@ def test_i_can_push():
|
||||
|
||||
|
||||
def test_children_i_created_when_i_push():
|
||||
e = ExecutionContext("who_", Event("event"), "fake_sheerka")
|
||||
e.push("a", desc="I do something")
|
||||
e.push("b", desc="oups! I did a again")
|
||||
e.push("c", desc="I do something else")
|
||||
e = ExecutionContext("who_", Event("event"), "fake_sheerka", BuiltinConcepts.NOP, None)
|
||||
e.push(BuiltinConcepts.NOP, None, who="a", desc="I do something")
|
||||
e.push(BuiltinConcepts.NOP, None, who="b", desc="oups! I did a again")
|
||||
e.push(BuiltinConcepts.NOP, None, who="c", desc="I do something else")
|
||||
|
||||
assert len(e.children) == 3
|
||||
assert e.children[0].who, e.children[0].who == ("a", "I do something")
|
||||
@@ -68,8 +71,8 @@ def test_children_i_created_when_i_push():
|
||||
|
||||
|
||||
def test_i_can_add_variable_when_i_push():
|
||||
e = ExecutionContext("who_", Event("event"), "fake_sheerka")
|
||||
sub_e = e.push("a", my_new_var="new var value")
|
||||
e = ExecutionContext("who_", Event("event"), "fake_sheerka", BuiltinConcepts.NOP, None)
|
||||
sub_e = e.push(BuiltinConcepts.NOP, None, who="a", my_new_var="new var value")
|
||||
|
||||
assert sub_e.my_new_var == "new var value"
|
||||
with pytest.raises(AttributeError):
|
||||
@@ -77,11 +80,11 @@ def test_i_can_add_variable_when_i_push():
|
||||
|
||||
|
||||
def test_local_hints_are_local_and_global_hints_are_global():
|
||||
a = ExecutionContext("foo", Event("event_1"), "fake_sheerka")
|
||||
a = ExecutionContext("foo", Event("event_1"), "fake_sheerka", BuiltinConcepts.NOP, None)
|
||||
a.local_hints.add("local hint 1")
|
||||
a.global_hints.add("global hint 1")
|
||||
|
||||
b = a.push()
|
||||
b = a.push(BuiltinConcepts.NOP, None)
|
||||
b.local_hints.add("local hint 2")
|
||||
b.global_hints.add("global hint 2")
|
||||
|
||||
@@ -93,9 +96,9 @@ def test_local_hints_are_local_and_global_hints_are_global():
|
||||
|
||||
|
||||
def test_global_hits_are_global_even_when_empty():
|
||||
a = ExecutionContext("foo", Event("event_1"), "fake_sheerka")
|
||||
a = ExecutionContext("foo", Event("event_1"), "fake_sheerka", BuiltinConcepts.NOP, None)
|
||||
|
||||
b = a.push()
|
||||
b = a.push(BuiltinConcepts.NOP, None)
|
||||
b.global_hints.add("global hint 2")
|
||||
|
||||
assert a.global_hints == {"global hint 2"}
|
||||
|
||||
@@ -68,7 +68,7 @@ class TestSheerkaFilter(TestUsingMemoryBasedSheerka):
|
||||
|
||||
def test_i_can_pipe_explanation_concept(self):
|
||||
sheerka, context = self.init_concepts()
|
||||
execution_contexts = [context.push(desc=f"desc_{i}") for i in range(4)]
|
||||
execution_contexts = [context.push(BuiltinConcepts.NOP, None, desc=f"desc_{i}") for i in range(4)]
|
||||
explanation_node = sheerka.new(BuiltinConcepts.EXPLANATION, body=execution_contexts)
|
||||
|
||||
@Pipe
|
||||
|
||||
@@ -219,7 +219,10 @@ class TestSheerkaPrinter(TestUsingMemoryBasedSheerka):
|
||||
sheerka = self.get_sheerka()
|
||||
context = self.get_context(sheerka)
|
||||
|
||||
execution_context = context.push("test_sheerka_printer", "Testing Execution Context Printing")
|
||||
execution_context = context.push(BuiltinConcepts.NOP,
|
||||
None,
|
||||
who="test_sheerka_printer",
|
||||
desc="Testing Execution Context Printing")
|
||||
ret_val = sheerka.ret("test_sheerka_printer", True, sheerka.new(BuiltinConcepts.SUCCESS))
|
||||
execution_context.add_values(return_value=ret_val)
|
||||
ec = execution_context.as_bag()
|
||||
|
||||
Reference in New Issue
Block a user