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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user