|
@@ -2206,6 +2206,186 @@ class TestModelverse(unittest.TestCase):
|
|
|
except NoSimpleClassDiagramsModel:
|
|
|
pass
|
|
|
|
|
|
+ def test_op_attribute_type(self):
|
|
|
+ model_add("users/user/test/a", "formalisms/SimpleClassDiagrams", """
|
|
|
+ SimpleAttribute String {}
|
|
|
+ SimpleAttribute Natural {}
|
|
|
+ Class A {
|
|
|
+ name = "ABC"
|
|
|
+ value : Natural
|
|
|
+ new_name ?: String
|
|
|
+ name : String
|
|
|
+ }
|
|
|
+ Association B (A, A) {
|
|
|
+ name = "DEF"
|
|
|
+ edge_value : Natural
|
|
|
+ name : String
|
|
|
+ other_value ?: String
|
|
|
+ }
|
|
|
+ Class C {}
|
|
|
+ Class D : A {
|
|
|
+ additional_attr : Natural
|
|
|
+ }
|
|
|
+ Association E : B (D, A) {
|
|
|
+ next_attr : String
|
|
|
+ }
|
|
|
+ """)
|
|
|
+
|
|
|
+ # Check initial situation
|
|
|
+ assert read_defined_attrs("users/user/test/a", "A") == ({"value": "Natural", "name": "String"}, {"new_name": "String"})
|
|
|
+ assert read_defined_attrs("users/user/test/a", "B") == ({"edge_value": "Natural", "name": "String"}, {"other_value": "String"})
|
|
|
+ assert read_defined_attrs("users/user/test/a", "C") == ({}, {})
|
|
|
+ assert read_defined_attrs("users/user/test/a", "D") == ({"value": "Natural", "name": "String", "additional_attr": "Natural"}, {"new_name": "String"})
|
|
|
+ assert read_defined_attrs("users/user/test/a", "E") == ({"edge_value": "Natural", "name": "String", "next_attr": "String"}, {"other_value": "String"})
|
|
|
+
|
|
|
+ # Change type of node
|
|
|
+ attribute_type("users/user/test/a", "A", "value", "String")
|
|
|
+ assert read_defined_attrs("users/user/test/a", "A") == ({"value": "String", "name": "String"}, {"new_name": "String"})
|
|
|
+ # Check inheritance as well
|
|
|
+ assert read_defined_attrs("users/user/test/a", "D") == ({"value": "String", "name": "String", "additional_attr": "Natural"}, {"new_name": "String"})
|
|
|
+
|
|
|
+ # Change type of edge
|
|
|
+ attribute_type("users/user/test/a", "B", "name", "Natural")
|
|
|
+ assert read_defined_attrs("users/user/test/a", "B") == ({"edge_value": "Natural", "name": "Natural"}, {"other_value": "String"})
|
|
|
+ # Check inheritance as well
|
|
|
+ assert read_defined_attrs("users/user/test/a", "E") == ({"edge_value": "Natural", "name": "Natural", "next_attr": "String"}, {"other_value": "String"})
|
|
|
+
|
|
|
+ # Non-existing model
|
|
|
+ try:
|
|
|
+ attribute_type("users/afa", "A", "value", "String")
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Non-existing element
|
|
|
+ before = element_list("users/user/test/a")
|
|
|
+ try:
|
|
|
+ attribute_type("users/user/test/a", "AA", "value", "String")
|
|
|
+ self.fail()
|
|
|
+ except UnknownElement:
|
|
|
+ assert element_list("users/user/test/a") == before
|
|
|
+
|
|
|
+ # Non-existing type
|
|
|
+ before = element_list("users/user/test/a")
|
|
|
+ try:
|
|
|
+ attribute_type("users/user/test/a", "A", "value", "SSS")
|
|
|
+ self.fail()
|
|
|
+ except UnknownElement:
|
|
|
+ assert element_list("users/user/test/a") == before
|
|
|
+
|
|
|
+ # No read permissions
|
|
|
+ try:
|
|
|
+ attribute_type("administration/core", "formalisms", "name", "Natural")
|
|
|
+ self.fail()
|
|
|
+ except ReadPermissionDenied:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # No write permissions, but can still query
|
|
|
+ before = element_list("formalisms/SimpleClassDiagrams")
|
|
|
+ try:
|
|
|
+ attribute_type("formalisms/SimpleClassDiagrams", "Class", "name", "Natural")
|
|
|
+ self.fail()
|
|
|
+ except WritePermissionDenied:
|
|
|
+ assert element_list("formalisms/SimpleClassDiagrams") == before
|
|
|
+
|
|
|
+ # None defined in non-SCD model
|
|
|
+ model_add("users/user/test/b", "users/user/test/a", "A a {}")
|
|
|
+ try:
|
|
|
+ attribute_type("users/user/test/b", "a", "b", "a")
|
|
|
+ self.fail()
|
|
|
+ except NoSimpleClassDiagramsModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ def test_op_attribute_name(self):
|
|
|
+ model_add("users/user/test/a", "formalisms/SimpleClassDiagrams", """
|
|
|
+ SimpleAttribute String {}
|
|
|
+ SimpleAttribute Natural {}
|
|
|
+ Class A {
|
|
|
+ name = "ABC"
|
|
|
+ value : Natural
|
|
|
+ new_name ?: String
|
|
|
+ name : String
|
|
|
+ }
|
|
|
+ Association B (A, A) {
|
|
|
+ name = "DEF"
|
|
|
+ edge_value : Natural
|
|
|
+ name : String
|
|
|
+ other_value ?: String
|
|
|
+ }
|
|
|
+ Class C {}
|
|
|
+ Class D : A {
|
|
|
+ additional_attr : Natural
|
|
|
+ }
|
|
|
+ Association E : B (D, A) {
|
|
|
+ next_attr : String
|
|
|
+ }
|
|
|
+ """)
|
|
|
+
|
|
|
+ # Check initial situation
|
|
|
+ assert read_defined_attrs("users/user/test/a", "A") == ({"value": "Natural", "name": "String"}, {"new_name": "String"})
|
|
|
+ assert read_defined_attrs("users/user/test/a", "B") == ({"edge_value": "Natural", "name": "String"}, {"other_value": "String"})
|
|
|
+ assert read_defined_attrs("users/user/test/a", "C") == ({}, {})
|
|
|
+ assert read_defined_attrs("users/user/test/a", "D") == ({"value": "Natural", "name": "String", "additional_attr": "Natural"}, {"new_name": "String"})
|
|
|
+ assert read_defined_attrs("users/user/test/a", "E") == ({"edge_value": "Natural", "name": "String", "next_attr": "String"}, {"other_value": "String"})
|
|
|
+
|
|
|
+ # Change name of node
|
|
|
+ attribute_name("users/user/test/a", "A", "value", "new_value")
|
|
|
+ assert read_defined_attrs("users/user/test/a", "A") == ({"new_value": "Natural", "name": "String"}, {"new_name": "String"})
|
|
|
+ # Check inheritance as well
|
|
|
+ assert read_defined_attrs("users/user/test/a", "D") == ({"new_value": "Natural", "name": "String", "additional_attr": "Natural"}, {"new_name": "String"})
|
|
|
+
|
|
|
+ # Change name of edge
|
|
|
+ attribute_name("users/user/test/a", "B", "name", "other_name")
|
|
|
+ assert read_defined_attrs("users/user/test/a", "B") == ({"edge_value": "Natural", "other_name": "String"}, {"other_value": "String"})
|
|
|
+ # Check inheritance as well
|
|
|
+ assert read_defined_attrs("users/user/test/a", "E") == ({"edge_value": "Natural", "other_name": "String", "next_attr": "String"}, {"other_value": "String"})
|
|
|
+
|
|
|
+ # Non-existing model
|
|
|
+ try:
|
|
|
+ attribute_name("users/afa", "A", "value", "str")
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Non-existing element
|
|
|
+ before = element_list("users/user/test/a")
|
|
|
+ try:
|
|
|
+ attribute_name("users/user/test/a", "AA", "value", "val2")
|
|
|
+ self.fail()
|
|
|
+ except UnknownElement:
|
|
|
+ assert element_list("users/user/test/a") == before
|
|
|
+
|
|
|
+ # Pre-existing name
|
|
|
+ before = element_list("users/user/test/a")
|
|
|
+ try:
|
|
|
+ attribute_name("users/user/test/a", "A", "new_value", "name")
|
|
|
+ self.fail()
|
|
|
+ except AttributeExists:
|
|
|
+ assert element_list("users/user/test/a") == before
|
|
|
+
|
|
|
+ # No read permissions
|
|
|
+ try:
|
|
|
+ attribute_name("administration/core", "formalisms", "name", "natural")
|
|
|
+ self.fail()
|
|
|
+ except ReadPermissionDenied:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # No write permissions, but can still query
|
|
|
+ before = element_list("formalisms/SimpleClassDiagrams")
|
|
|
+ try:
|
|
|
+ attribute_name("formalisms/SimpleClassDiagrams", "Class", "name", "value")
|
|
|
+ self.fail()
|
|
|
+ except WritePermissionDenied:
|
|
|
+ assert element_list("formalisms/SimpleClassDiagrams") == before
|
|
|
+
|
|
|
+ # None defined in non-SCD model
|
|
|
+ model_add("users/user/test/b", "users/user/test/a", "A a {}")
|
|
|
+ try:
|
|
|
+ attribute_name("users/user/test/b", "a", "b", "c")
|
|
|
+ self.fail()
|
|
|
+ except NoSimpleClassDiagramsModel:
|
|
|
+ pass
|
|
|
+
|
|
|
"""
|
|
|
def test_op_model_render(self):
|
|
|
def test_op_transformation_between(self):
|
|
@@ -2228,8 +2408,6 @@ class TestModelverse(unittest.TestCase):
|
|
|
def test_op_group_list(self):
|
|
|
def test_op_conformance_delete(self):
|
|
|
def test_op_conformance_add(self):
|
|
|
- def test_op_attribute_type(self):
|
|
|
- def test_op_attribute_name(self):
|
|
|
"""
|
|
|
|
|
|
def test_modelling(self):
|