Fixed #61 : SheerkaDebugManager: Add get_value()
Fixed #60 : Hash error when ReturnValue is a list of list Fixed #59 : Implement smart_get() Fixed #58 : SheerkaPromptCompleter: Cannot parse concept token Fixed #57 : SheerkaPrompt: Add concept autocompletion Fixed #56 : automatically backup command Fixed #54 : I can record execution status Fixed #53 : ConceptManager: modify_concept fails
This commit is contained in:
@@ -3,6 +3,10 @@ import types
|
||||
import pytest
|
||||
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.concept import Concept
|
||||
from core.global_symbols import EVENT_CONCEPT_CREATED, EVENT_CONCEPT_MODIFIED, EVENT_CONCEPT_PRECEDENCE_MODIFIED, \
|
||||
EVENT_RULE_PRECEDENCE_MODIFIED
|
||||
from core.rule import Rule, ACTION_TYPE_EXEC
|
||||
from core.sheerka.ExecutionContext import ExecutionContext
|
||||
from core.sheerka.SheerkaOntologyManager import SheerkaOntologyManager
|
||||
from core.sheerka.services.SheerkaResultManager import SheerkaResultManager
|
||||
@@ -400,6 +404,51 @@ class TestSheerkaResultManager(TestUsingMemoryBasedSheerka):
|
||||
assert service.last_error_event_id is None
|
||||
assert sheerka.get_last_error() == self.sheerka.new(BuiltinConcepts.NOT_FOUND, body={"query": "get_last_error"})
|
||||
|
||||
@pytest.mark.parametrize("event_id, event_args", [
|
||||
(EVENT_CONCEPT_CREATED, Concept("foo")),
|
||||
(EVENT_CONCEPT_MODIFIED, {"old": Concept("foo"), "new": Concept("bar")}),
|
||||
(EVENT_CONCEPT_PRECEDENCE_MODIFIED, None),
|
||||
(EVENT_RULE_PRECEDENCE_MODIFIED, None),
|
||||
])
|
||||
def test_i_can_detect_when_the_global_state_has_change(self, event_id, event_args):
|
||||
sheerka, context = self.init_test().unpack()
|
||||
assert not context.is_state_modified()
|
||||
|
||||
if event_args:
|
||||
sheerka.publish(context, event_id, event_args)
|
||||
else:
|
||||
sheerka.publish(context, event_id)
|
||||
assert context.is_state_modified()
|
||||
|
||||
def test_i_can_detect_when_the_global_state_has_change_when_a_concept_is_deleted(self):
|
||||
sheerka, context, foo = self.init_concepts("foo", create_new=True)
|
||||
del context.values["is_state_modified"]
|
||||
assert not context.is_state_modified()
|
||||
|
||||
with context.push("Testing state", None) as sub_context:
|
||||
sheerka.remove_concept(sub_context, foo)
|
||||
|
||||
assert context.is_state_modified()
|
||||
|
||||
def test_i_can_detect_when_the_global_state_has_change_when_a_rule_is_created(self):
|
||||
sheerka, context = self.init_test().unpack()
|
||||
|
||||
rule = Rule(ACTION_TYPE_EXEC, "testing state has change", "True", "'hello world'")
|
||||
with context.push("Testing state", None) as sub_context:
|
||||
sheerka.create_new_rule(sub_context, rule)
|
||||
|
||||
assert context.is_state_modified()
|
||||
|
||||
def test_i_can_detect_when_the_global_state_has_change_when_a_rule_is_deleted(self):
|
||||
sheerka, context, rule = self.init_exec_rules(("testing state has change", "True", "'hello world'"))
|
||||
del context.values["is_state_modified"]
|
||||
assert not context.is_state_modified()
|
||||
|
||||
with context.push("Testing state", None) as sub_context:
|
||||
sheerka.remove_rule(sub_context, rule)
|
||||
|
||||
assert context.is_state_modified()
|
||||
|
||||
|
||||
class TestSheerkaResultManagerFileBased(TestUsingFileBasedSheerka):
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user