Fixed #68: Implement SheerkaQL
Fixed #70: SheerkaFilterManager : Pipe functions Fixed #71: SheerkaFilterManager : filter_objects Fixed #75: SheerkaMemory: Enhance memory() to use the filtering capabilities Fixed #76: SheerkaEvaluateConcept: Concepts that modify the state of the system must not be evaluated during question
This commit is contained in:
@@ -87,7 +87,9 @@ class TestSheerkaMemory(TestUsingMemoryBasedSheerka):
|
||||
foo = Concept("foo")
|
||||
sheerka.add_to_memory(context, "a", foo)
|
||||
|
||||
assert sheerka.om.copy(SheerkaMemory.OBJECTS_ENTRY) == {"a": MemoryObject(context.event.get_digest(), foo)}
|
||||
assert sheerka.om.copy(SheerkaMemory.OBJECTS_ENTRY) == {"a": MemoryObject(context.event.get_digest(),
|
||||
context.event.date.timestamp(),
|
||||
foo)}
|
||||
assert id(sheerka.get_from_memory(context, "a").obj) == id(foo)
|
||||
|
||||
def test_i_can_use_memory_with_a_string(self):
|
||||
@@ -106,6 +108,44 @@ class TestSheerkaMemory(TestUsingMemoryBasedSheerka):
|
||||
|
||||
assert sheerka.memory(context, Concept("foo")) == foo
|
||||
|
||||
def test_i_can_use_memory_with_a_query(self):
|
||||
sheerka, context, foo, bar = self.init_concepts("foo", "bar")
|
||||
|
||||
sheerka.add_to_memory(context, "x", foo)
|
||||
sheerka.add_to_memory(context, "y", bar)
|
||||
|
||||
assert sheerka.memory(context, "self.name == 'foo'") == foo
|
||||
|
||||
def test_i_retrieve_the_last_entry_when_requesting_memory_with_a_query(self):
|
||||
sheerka, context, foo, bar, foo2 = self.init_concepts("foo", "bar", Concept("foo", body="2"))
|
||||
|
||||
sheerka.add_to_memory(context, "x", foo)
|
||||
sheerka.add_to_memory(context, "y", bar)
|
||||
|
||||
context2 = self.get_context(sheerka) # timestamp is newer
|
||||
sheerka.add_to_memory(context2, "z", foo2)
|
||||
|
||||
assert sheerka.memory(context, "self.name == 'foo'") == foo2
|
||||
|
||||
def test_i_can_look_in_the_previous_objects_when_using_query_to_request_the_memory(self):
|
||||
sheerka, context, foo, bar, baz = self.init_concepts("foo", "bar", "baz")
|
||||
|
||||
sheerka.add_to_memory(context, "x", foo)
|
||||
sheerka.add_to_memory(context, "y", bar)
|
||||
sheerka.add_to_memory(context, "z", baz)
|
||||
|
||||
# another layer
|
||||
sheerka.add_to_memory(context, "x", bar)
|
||||
sheerka.add_to_memory(context, "y", baz)
|
||||
|
||||
# another layer
|
||||
sheerka.add_to_memory(context, "x", baz)
|
||||
|
||||
# so under x there is [foo] -> [bar] -> [baz]
|
||||
# so under y there is [bar] -> [baz]
|
||||
# so under z there is [baz]
|
||||
assert sheerka.memory(context, "self.name == 'foo'") == foo
|
||||
|
||||
def test_concept_not_found_is_return_when_not_found(self):
|
||||
sheerka, context = self.init_test().unpack()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user