cac2dad17f
Fixed #2 : Variables are not recognized when inside a rule token Fixed #15 : Rule: rete attributes are lost when a new ontology is created Fixed #14 : ReteNetwork: Format rules must not be added to Rete network Fixed #16 : DefConcept: Variables are not recognized when they are keyword arguments Fixed #4 : Comparison are not correctly set when comparison property is a concept Fixed #14 : Parser: merge FunctionParser.NamesNode and ExpressionParser.NamesNode Fixed #18 : Parser: Add SourceCodeNode test to UnrecognizedNodeParser Fixed #20 : At startup Number concept is saved in db a numerous number of time Fixed #21 : CacheManager: I can remove all elements from a ListIfNeededCache and fill it again Fixed #22 : CacheManager: I can remove all elements from a SetCache and fill it again Fixed #23 : HistoryManager: history() no longer works Fixed #24 : HistoryManager: history() no longer works after creating an exec rule Fixed #25 : SheerkaMemory: Use MemoryObject instead of sheerka.local Fixed #26 : Debugger: add the list all available services.. Fixed #27 : CONCEPTS_GRAMMARS_ENTRY does not seems to be in use any more Fixed #28 : Give order to services
41 lines
1.6 KiB
Python
41 lines
1.6 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)
|
|
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
|