from core.builtin_concepts import BuiltinConcepts from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka class TestSheerkaHasAManager(TestUsingMemoryBasedSheerka): def test_i_can_set_hasa(self): sheerka, context, king, kingdom = self.init_concepts("king", "kingdom") res = sheerka.set_hasa(context, sheerka.new("king"), kingdom) assert res.status another_king = sheerka.get_by_key("king") assert another_king.get_prop(BuiltinConcepts.HASA) == {kingdom} # check that the definition of the concept has been updated assert sheerka.hasa(sheerka.new("king"), kingdom) def test_i_cannot_set_the_same_attribute_twice(self): sheerka, context, king, kingdom = self.init_concepts("king", "kingdom") sheerka.set_hasa(context, sheerka.new("king"), kingdom) res = sheerka.set_hasa(context, sheerka.new("king"), kingdom) assert not res.status assert sheerka.isinstance(res.body, BuiltinConcepts.PROPERTY_ALREADY_DEFINED) assert res.body.property_name == BuiltinConcepts.HASA assert res.body.property_value == kingdom assert res.body.concept == sheerka.new("king")