|
@@ -1206,6 +1206,67 @@ class TestModelverse(unittest.TestCase):
|
|
|
attr_delete("users/user/test/a", "Place", "constraint")
|
|
|
assert read_attrs("users/user/test/a", "Place") == {"constraint": {"AL": ""}, "name": "Place", "abstract": None, "lower_cardinality": None, "upper_cardinality": None}
|
|
|
|
|
|
+ def test_op_attr_assign_code(self):
|
|
|
+ model_add("users/user/test/a", "formalisms/SimpleClassDiagrams", """
|
|
|
+ SimpleAttribute Natural {
|
|
|
+ name = "natural"
|
|
|
+ }
|
|
|
+ SimpleAttribute String {
|
|
|
+ name = "string"
|
|
|
+ }
|
|
|
+
|
|
|
+ Class Place {
|
|
|
+ name = "Place"
|
|
|
+ name : String
|
|
|
+ capacity : Natural
|
|
|
+ }
|
|
|
+ Class Transition {
|
|
|
+ name = "Transition"
|
|
|
+ name : String
|
|
|
+ }
|
|
|
+ Association P2T (Place, Transition) {
|
|
|
+ name = "P2T"
|
|
|
+ weight : Natural
|
|
|
+ }
|
|
|
+ Association T2P (Transition, Place) {
|
|
|
+ name = "T2P"
|
|
|
+ weight : Natural
|
|
|
+ }
|
|
|
+ """)
|
|
|
+
|
|
|
+ # Test ordinary case
|
|
|
+ assert read_attrs("users/user/test/a", "Place") == {"constraint": {"AL": ""}, "name": "Place", "abstract": None, "lower_cardinality": None, "upper_cardinality": None}
|
|
|
+ assert attr_assign_code("users/user/test/a", "Place", "constraint", """
|
|
|
+ String function a(value : Element):
|
|
|
+ return "OK"!
|
|
|
+ """) == None
|
|
|
+ attrs = read_attrs("users/user/test/a", "Place")
|
|
|
+ assert "AL" in attrs["constraint"]
|
|
|
+ assert attrs["constraint"]["AL"] != ""
|
|
|
+
|
|
|
+ assert AL_text(attrs["constraint"]["AL"]).strip() == """
|
|
|
+ String function a(value : Element):
|
|
|
+ return "OK"!
|
|
|
+ """.strip()
|
|
|
+
|
|
|
+ # Test assign when already assigned
|
|
|
+ attrs = read_attrs("users/user/test/a", "Place")
|
|
|
+ old_location = attrs["constraint"]["AL"]
|
|
|
+ old_text = AL_text(attrs["constraint"]["AL"])
|
|
|
+ assert attr_assign_code("users/user/test/a", "Place", "constraint", """
|
|
|
+ String function a(value : Element):
|
|
|
+ return "NOK"!
|
|
|
+ """) == None
|
|
|
+ attrs = read_attrs("users/user/test/a", "Place")
|
|
|
+ assert "AL" in attrs["constraint"]
|
|
|
+ assert attrs["constraint"]["AL"] != ""
|
|
|
+ assert attrs["constraint"]["AL"] != old_location
|
|
|
+ assert AL_text(attrs["constraint"]["AL"]).strip() == """
|
|
|
+ String function a(value : Element):
|
|
|
+ return "NOK"!
|
|
|
+ """.strip()
|
|
|
+ assert AL_text(attrs["constraint"]["AL"]).strip () != old_text.strip()
|
|
|
+
|
|
|
"""
|
|
|
def test_op_model_render(self):
|
|
|
def test_op_transformation_between(self):
|
|
@@ -1230,7 +1291,6 @@ class TestModelverse(unittest.TestCase):
|
|
|
def test_op_conformance_add(self):
|
|
|
def test_op_instantiate(self):
|
|
|
def test_op_delete_element(self):
|
|
|
- def test_op_attr_assign_code(self):
|
|
|
def test_op_AL_text(self):
|
|
|
def test_op_read_outgoing(self):
|
|
|
def test_op_read_incoming(self):
|