Implemented some enhancement request and fixed some bugs
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
This commit is contained in:
@@ -88,7 +88,6 @@ class TestSheerkaMemory(TestUsingMemoryBasedSheerka):
|
||||
assert sheerka.om.copy(SheerkaMemory.OBJECTS_ENTRY) == {"a": MemoryObject(context.event.get_digest(), foo)}
|
||||
assert id(sheerka.get_from_memory(context, "a").obj) == id(foo)
|
||||
|
||||
|
||||
def test_i_can_use_memory_with_a_string(self):
|
||||
sheerka, context = self.init_test().unpack()
|
||||
|
||||
@@ -129,6 +128,69 @@ class TestSheerkaMemory(TestUsingMemoryBasedSheerka):
|
||||
|
||||
assert len(sheerka.om.get_all(SheerkaMemory.OBJECTS_ENTRY)) == 0
|
||||
|
||||
def test_adding_the_same_object_with_same_context_has_no_effect_when_one_element(self):
|
||||
sheerka, context, foo = self.init_concepts("foo")
|
||||
service = sheerka.services[SheerkaMemory.NAME]
|
||||
|
||||
sheerka.add_to_memory(context, "item", foo)
|
||||
from_memory = service.get_from_memory(context, "item")
|
||||
|
||||
sheerka.add_to_memory(context, "item", foo)
|
||||
from_memory_again = service.get_from_memory(context, "item")
|
||||
assert from_memory_again == from_memory
|
||||
|
||||
def test_adding_the_same_object_with_same_context_has_no_effect_when_multiple_elements(self):
|
||||
sheerka, context, foo, bar, baz = self.init_concepts("foo", "bar", "baz")
|
||||
service = sheerka.services[SheerkaMemory.NAME]
|
||||
|
||||
sheerka.add_to_memory(context, "item", foo)
|
||||
sheerka.add_to_memory(context, "item", bar)
|
||||
sheerka.add_to_memory(context, "item", baz)
|
||||
from_memory = service.get_from_memory(context, "item").copy()
|
||||
|
||||
sheerka.add_to_memory(context, "item", baz)
|
||||
from_memory_again = service.get_from_memory(context, "item")
|
||||
assert from_memory_again == from_memory
|
||||
|
||||
def test_adding_the_same_object_with_a_different_context_updates_event_id_when_one_element(self):
|
||||
sheerka, context1, foo = self.init_concepts("foo")
|
||||
service = sheerka.services[SheerkaMemory.NAME]
|
||||
|
||||
sheerka.add_to_memory(context1, "item", foo)
|
||||
from_memory = service.get_from_memory(context1, "item")
|
||||
|
||||
context2 = self.get_context(self.sheerka, message="another message")
|
||||
sheerka.add_to_memory(context2, "item", foo)
|
||||
from_memory_again = service.get_from_memory(context2, "item")
|
||||
|
||||
assert from_memory_again != from_memory
|
||||
assert not isinstance(from_memory_again, list)
|
||||
|
||||
assert from_memory_again.obj == from_memory.obj
|
||||
assert from_memory_again.event_id == context2.event.get_digest()
|
||||
assert from_memory.event_id == context1.event.get_digest()
|
||||
|
||||
def test_adding_the_same_object_with_a_different_context_updates_event_id_when_multiple_elements(self):
|
||||
sheerka, context, foo, bar, baz = self.init_concepts("foo", "bar", "baz")
|
||||
service = sheerka.services[SheerkaMemory.NAME]
|
||||
|
||||
sheerka.add_to_memory(context, "item", foo)
|
||||
sheerka.add_to_memory(context, "item", bar)
|
||||
sheerka.add_to_memory(context, "item", baz)
|
||||
from_memory = service.get_from_memory(context, "item").copy()
|
||||
|
||||
context2 = self.get_context(self.sheerka, message="another message")
|
||||
sheerka.add_to_memory(context2, "item", baz)
|
||||
from_memory_again = service.get_from_memory(context2, "item")
|
||||
|
||||
assert isinstance(from_memory_again, list)
|
||||
assert len(from_memory) == len(from_memory_again)
|
||||
for mo, mo_again in zip(from_memory, from_memory_again[:-1]):
|
||||
assert mo == mo_again
|
||||
|
||||
assert from_memory[-1].obj == from_memory_again[-1].obj
|
||||
assert from_memory[-1].event_id != from_memory_again[-1].event_id
|
||||
|
||||
|
||||
class TestSheerkaMemoryUsingFileBase(TestUsingFileBasedSheerka):
|
||||
def test_i_can_record_memory_objects(self):
|
||||
|
||||
Reference in New Issue
Block a user