Fixed #32 : concept groups are not correctly updated
Fixed #35 : Refactor test helper class (CNC, CC, CIO) Fixed #36 : Concept values are not used when declared with variable expression Fixed #37 : Objects in memory lose their values are restart Fixed #38 : func(a=b, c) (which is not allowed) raise an exception
This commit is contained in:
+20
-12
@@ -1,7 +1,9 @@
|
||||
import pytest
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
|
||||
from core.concept import Concept, ConceptParts, DEFINITION_TYPE_DEF, ALL_ATTRIBUTES, get_concept_attrs
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.concept import Concept, ConceptParts, DEFINITION_TYPE_DEF, ALL_ATTRIBUTES, get_concept_attrs, \
|
||||
freeze_concept_attrs
|
||||
from core.global_symbols import NotInit
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name, variables, expected", [
|
||||
@@ -121,6 +123,7 @@ def test_i_can_deserialize():
|
||||
}
|
||||
|
||||
concept = Concept().from_dict(from_dict)
|
||||
freeze_concept_attrs(concept)
|
||||
|
||||
assert concept == Concept(
|
||||
name="concept_name",
|
||||
@@ -281,16 +284,21 @@ def test_i_can_manage_concepts_attributes():
|
||||
assert concept.values() == {"#body#": "I have a body!"}
|
||||
|
||||
|
||||
def test_attributes_are_generated_once_for_all():
|
||||
def test_i_can_manage_instance_attributes():
|
||||
ALL_ATTRIBUTES.clear()
|
||||
concept = Concept("foo")
|
||||
concept.get_metadata().id = "id"
|
||||
|
||||
concept.set_value("key1", "value1")
|
||||
concept.set_value("key2", "value2")
|
||||
assert get_concept_attrs(concept) == ["key1", "key2"]
|
||||
assert concept.values() == {"key1": "value1", "key2": "value2"}
|
||||
foo = Concept("foo", id="foo_id").def_var("x")
|
||||
|
||||
concept.set_value("key3", "value3") # too late for it !
|
||||
assert get_concept_attrs(concept) == ["key1", "key2"]
|
||||
assert concept.values() == {"key1": "value1", "key2": "value2"}
|
||||
assert foo.values() == {"x": NotInit}
|
||||
assert foo.get_all_attributes() is None
|
||||
assert ALL_ATTRIBUTES == {"foo_id": ["x"]}
|
||||
|
||||
foo.set_value("x", "value for x")
|
||||
assert foo.values() == {"x": "value for x"}
|
||||
assert foo.get_all_attributes() is None
|
||||
assert ALL_ATTRIBUTES == {"foo_id": ["x"]}
|
||||
|
||||
foo.set_value("y", "value for y")
|
||||
assert foo.values() == {"x": "value for x", "y": "value for y"}
|
||||
assert foo.get_all_attributes() == ["x", "y"]
|
||||
assert ALL_ATTRIBUTES == {"foo_id": ["x"]}
|
||||
|
||||
Reference in New Issue
Block a user