Fixed #101 : Implement PLURIAL
Fixed #103 : Implement PlurialNodeParser Fixed #104 : Implement dynamic concept Fixed #107 : PrepareEvalxxxEvaluator: context hints are lost on a second evaluation
This commit is contained in:
@@ -159,7 +159,7 @@ class TestSheerkaPickleHandler(TestUsingMemoryBasedSheerka):
|
||||
to_string = sheerkapickle.encode(sheerka, ref_concept)
|
||||
decoded = sheerkapickle.decode(sheerka, to_string)
|
||||
assert decoded == ref_concept
|
||||
assert to_string == '{"_sheerka/obj": "core.concept.Concept", "concept/id": ["my_key", "1001"]}'
|
||||
assert to_string == '{"_sheerka/obj": "core.concept.Concept", "concept/id": "1001"}'
|
||||
|
||||
# same test, modify a value and check if this modification is correctly saved
|
||||
concept = Concept().update_from(sheerka.get_by_id(ref_concept.id))
|
||||
@@ -167,26 +167,7 @@ class TestSheerkaPickleHandler(TestUsingMemoryBasedSheerka):
|
||||
to_string = sheerkapickle.encode(sheerka, concept)
|
||||
decoded = sheerkapickle.decode(sheerka, to_string)
|
||||
assert decoded == concept
|
||||
assert to_string == '{"_sheerka/obj": "core.concept.Concept", "concept/id": ["my_key", "1001"], "values": [["#body#", {"_sheerka/obj": "core.concept.Concept", "meta.name": "bar"}]]}'
|
||||
|
||||
# def test_i_can_encode_decode_when_variable_is_a_concept(self):
|
||||
# sheerka = self.get_sheerka()
|
||||
#
|
||||
# foo = Concept("foo")
|
||||
# sheerka.create_new_concept(self.get_context(sheerka), foo)
|
||||
#
|
||||
# concept = Concept("my_name")
|
||||
# sheerka.create_new_concept(self.get_context(sheerka), concept)
|
||||
# concept.def_var(foo, "a value")
|
||||
# concept.set_value(foo, "another value")
|
||||
# concept.get_metadata().full_serialization = True
|
||||
#
|
||||
# to_string = sheerkapickle.encode(sheerka, concept)
|
||||
# decoded = sheerkapickle.decode(sheerka, to_string)
|
||||
# assert decoded == concept
|
||||
# assert to_string == '{"_sheerka/obj": "core.concept.Concept", "meta.name": "my_name", "meta.key": "my_name", ' + \
|
||||
# '"meta.variables": [[{"_sheerka/obj": "core.concept.Concept", "concept/id": ["foo", "1001"]}, "a value"]], ' + \
|
||||
# '"meta.id": "1002", "values": [[{"_sheerka/id": 1}, "another value"]]}'
|
||||
assert to_string == '{"_sheerka/obj": "core.concept.Concept", "concept/id": "1001", "values": [["#body#", {"_sheerka/obj": "core.concept.Concept", "meta.name": "bar"}]]}'
|
||||
|
||||
def test_i_can_manage_reference_of_the_same_object(self):
|
||||
sheerka = self.get_sheerka()
|
||||
@@ -331,7 +312,7 @@ class TestSheerkaPickleHandler(TestUsingMemoryBasedSheerka):
|
||||
def test_i_can_encode_decode_rule(self):
|
||||
sheerka = self.get_sheerka()
|
||||
|
||||
rule = Rule("print", "my rule", "True","Hello world")
|
||||
rule = Rule("print", "my rule", "True", "Hello world")
|
||||
rule.metadata.id = "1"
|
||||
|
||||
to_string = sheerkapickle.encode(sheerka, rule)
|
||||
@@ -339,3 +320,21 @@ class TestSheerkaPickleHandler(TestUsingMemoryBasedSheerka):
|
||||
|
||||
assert to_string == '{"_sheerka/obj": "core.rule.Rule", "rule/id": "1", "name": "my rule", "predicate": "True", "action_type": "print", "action": "Hello world"}'
|
||||
assert decoded == rule
|
||||
|
||||
def test_i_can_encode_decode_dynamic_concept(self):
|
||||
sheerka, context, foo = self.init_concepts("foo", global_truth=True, create_new=True)
|
||||
sheerka.set_attr(context, foo, "attr", "attr_value")
|
||||
sheerka.set_property(context, foo, "prop", "prop_value", all_concepts=True)
|
||||
|
||||
foo_instance = sheerka.new(foo)
|
||||
dynamic_foo = sheerka.new_dynamic(foo_instance,
|
||||
"SUFFIX",
|
||||
"new_name",
|
||||
props={"new_prop": "value"},
|
||||
attrs={"new_attr": "value"})
|
||||
|
||||
to_string = sheerkapickle.encode(sheerka, dynamic_foo)
|
||||
decoded = sheerkapickle.decode(sheerka, to_string)
|
||||
|
||||
assert decoded == dynamic_foo
|
||||
assert to_string == '{"_sheerka/obj": "core.concept.Concept", "concept/id": "1001-SUFFIX", "meta.name": "new_name", "meta.key": "new_name", "meta.props": {"prop": "prop_value", "new_prop": "value"}, "meta.id": "1001-SUFFIX", "values": [["new_attr", "value"]]}'
|
||||
|
||||
Reference in New Issue
Block a user