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:
2021-04-26 19:13:47 +02:00
parent bef5f3208c
commit 1059ce25c5
57 changed files with 5759 additions and 1302 deletions
+25
View File
@@ -469,3 +469,28 @@ def test_tokens_are_matching_when_eof_differs():
tokens2 = Tokenizer(expression2, yield_eof=False)
assert core.utils.tokens_are_matching(tokens1, tokens2)
def test_sheerka_hasattr_get_attr():
class A:
def __init__(self, property_value):
self.property_value = property_value
def as_bag(self):
return {"prop": self.property_value}
# test object with bag
a = A("foo")
assert core.utils.sheerka_hasattr(a, "prop")
assert core.utils.sheerka_getattr(a, "prop") == "foo"
assert not core.utils.sheerka_hasattr(a, "property_value")
with pytest.raises(AttributeError):
core.utils.sheerka_getattr(a, "property_value")
# test for concept
concept = Concept("foo").def_var("a", "value").auto_init()
assert core.utils.sheerka_hasattr(concept, "a")
assert core.utils.sheerka_getattr(concept, "a") == "value"
assert not core.utils.sheerka_hasattr(concept, "b")
with pytest.raises(AttributeError):
core.utils.sheerka_getattr(concept, "b")