dd3d8f4abe
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
42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
from core.sheerka.Sheerka import Sheerka
|
|
from core.sheerka.SheerkaOntologyManager import SheerkaOntologyManager
|
|
|
|
from tests.BaseTest import BaseTest
|
|
|
|
|
|
class TestUsingMemoryBasedSheerka(BaseTest):
|
|
sheerka = None
|
|
context = None
|
|
root_ontology_name = SheerkaOntologyManager.ROOT_ONTOLOGY_NAME
|
|
|
|
def teardown_method(self, method):
|
|
# to do after the test
|
|
if TestUsingMemoryBasedSheerka.sheerka:
|
|
while TestUsingMemoryBasedSheerka.sheerka.om.current_ontology().name != self.root_ontology_name:
|
|
TestUsingMemoryBasedSheerka.sheerka.pop_ontology(self.context)
|
|
|
|
for service_name, service in TestUsingMemoryBasedSheerka.sheerka.services.items():
|
|
if hasattr(service, "reset_state"):
|
|
service.reset_state()
|
|
|
|
@staticmethod
|
|
def new_sheerka_instance(cache_only):
|
|
sheerka = Sheerka(cache_only=cache_only)
|
|
sheerka.initialize("mem://",
|
|
save_execution_context=False,
|
|
enable_process_return_values=False,
|
|
enable_process_rules=False,
|
|
enable_commands_backup=False)
|
|
return sheerka
|
|
|
|
def get_sheerka(self, **kwargs) -> Sheerka:
|
|
cache_only = kwargs.get("cache_only", True)
|
|
ontology_name = kwargs.get("ontology", "#unit_test#") or "#unit_test#"
|
|
|
|
if TestUsingMemoryBasedSheerka.sheerka is None:
|
|
TestUsingMemoryBasedSheerka.sheerka = self.new_sheerka_instance(False)
|
|
TestUsingMemoryBasedSheerka.context = self.get_context(TestUsingMemoryBasedSheerka.sheerka)
|
|
|
|
self.sheerka.push_ontology(self.context, ontology_name, cache_only=cache_only)
|
|
return self.sheerka
|