|
@@ -1162,6 +1162,50 @@ class TestModelverse(unittest.TestCase):
|
|
|
except UnknownAttribute:
|
|
|
pass
|
|
|
|
|
|
+ def test_op_attr_delete_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 what happens if removing a non-existing AL attribute
|
|
|
+ assert read_attrs("users/user/test/a", "Place") == {"constraint": {"AL": ""}, "name": "Place", "abstract": None, "lower_cardinality": None, "upper_cardinality": None}
|
|
|
+ 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}
|
|
|
+
|
|
|
+ # Test what happens if removing an existing AL attribute
|
|
|
+ attr_assign_code("users/user/test/a", "Place", "constraint", """
|
|
|
+ String function a(value : Element):
|
|
|
+ return "OK"!
|
|
|
+ """)
|
|
|
+ attrs = read_attrs("users/user/test/a", "Place")
|
|
|
+ assert "AL" in attrs["constraint"]
|
|
|
+ assert attrs["constraint"]["AL"] != ""
|
|
|
+ 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_model_render(self):
|
|
|
def test_op_transformation_between(self):
|