Working on #98 : Persist attribute value when global_truth is set to true
This commit is contained in:
@@ -64,10 +64,10 @@ def test_i_can_serialize():
|
||||
:return:
|
||||
"""
|
||||
concept = Concept(
|
||||
name="concept_name",
|
||||
name="concept_name a",
|
||||
is_builtin=True,
|
||||
is_unique=True,
|
||||
key="concept_key",
|
||||
key=None,
|
||||
body="definition of the body",
|
||||
where="definition of the where",
|
||||
pre="definition of the pre",
|
||||
@@ -78,6 +78,8 @@ def test_i_can_serialize():
|
||||
desc="this this the desc",
|
||||
id="123456"
|
||||
).def_var("a", "10").def_var("b", None)
|
||||
concept.get_metadata().parameters = ["a"]
|
||||
concept.init_key()
|
||||
|
||||
to_dict = concept.to_dict()
|
||||
assert to_dict == {
|
||||
@@ -88,14 +90,15 @@ def test_i_can_serialize():
|
||||
'id': '123456',
|
||||
'is_builtin': True,
|
||||
'is_unique': True,
|
||||
'key': 'concept_key',
|
||||
'name': 'concept_name',
|
||||
'key': 'concept_name __var__0',
|
||||
'name': 'concept_name a',
|
||||
'post': 'definition of the post',
|
||||
'pre': 'definition of the pre',
|
||||
'ret': "concept to return",
|
||||
'props': {},
|
||||
'variables': [('a', "10"), ('b', None)],
|
||||
'where': 'definition of the where'
|
||||
'where': 'definition of the where',
|
||||
'parameters': ['a'],
|
||||
}
|
||||
|
||||
|
||||
@@ -302,3 +305,33 @@ def test_i_can_manage_instance_attributes():
|
||||
assert foo.values() == {"x": "value for x", "y": "value for y"}
|
||||
assert foo.get_all_attributes() == ["x", "y"]
|
||||
assert ALL_ATTRIBUTES == {"foo_id": ["x"]}
|
||||
|
||||
|
||||
def test_i_can_init_key_and_compute_parameters():
|
||||
concept = Concept("foo x").def_var("x").init_key()
|
||||
assert concept.key == "foo __var__0"
|
||||
|
||||
concept = Concept("foo").def_var("x").init_key()
|
||||
assert concept.key == "foo"
|
||||
|
||||
concept = Concept("foo a b").def_var("a").def_var("b").init_key()
|
||||
assert concept.key == "foo __var__0 __var__1"
|
||||
|
||||
concept = Concept("foo a b").def_var("b").def_var("a").init_key()
|
||||
assert concept.key == "foo __var__1 __var__0"
|
||||
|
||||
concept = Concept("foo a b").def_var("a").init_key()
|
||||
assert concept.key == "foo __var__0 b"
|
||||
|
||||
concept = Concept("foo a b").def_var("b").init_key()
|
||||
assert concept.key == "foo a __var__0"
|
||||
|
||||
concept = Concept("foo a").def_var("a").def_var("b").init_key()
|
||||
assert concept.key == "foo __var__0"
|
||||
|
||||
concept = Concept("foo b").def_var("a").def_var("b").init_key()
|
||||
assert concept.key == "foo __var__1"
|
||||
|
||||
concept = Concept("plus", definition_type=DEFINITION_TYPE_DEF, definition="a plus b").def_var("a").def_var("b")
|
||||
concept.init_key()
|
||||
assert concept.key == "__var__0 plus __var__1"
|
||||
|
||||
Reference in New Issue
Block a user