From ce502a48a0cef7ad12c21456ef04b7edf77dbb5a Mon Sep 17 00:00:00 2001 From: huyenngn Date: Tue, 12 Mar 2024 15:36:00 +0100 Subject: [PATCH] fix: Add kind to props --- capella_ros_tools/importer.py | 1 + tests/data/data_model/example_msgs.yaml | 8 ++++++++ tests/test_import_msgs.py | 3 +++ 3 files changed, 12 insertions(+) diff --git a/capella_ros_tools/importer.py b/capella_ros_tools/importer.py index b110f3f..2345030 100644 --- a/capella_ros_tools/importer.py +++ b/capella_ros_tools/importer.py @@ -111,6 +111,7 @@ def _convert_class( prop_yml = { "name": field_def.name, "type": decl.Promise(promise_ref), + "kind": "COMPOSITION", "description": field_def.description, "min_card": decl.NewObject( "LiteralNumericValue", value=field_def.type.card.min diff --git a/tests/data/data_model/example_msgs.yaml b/tests/data/data_model/example_msgs.yaml index 61c9778..d297411 100644 --- a/tests/data/data_model/example_msgs.yaml +++ b/tests/data/data_model/example_msgs.yaml @@ -18,6 +18,7 @@ - name: sample_field1 description: "This block comment is added to the property description of sample_field1. This block comment is also added to the property description of sample_field1. " type: !promise package1.uint8 + kind: COMPOSITION min_card: !new_object _type: LiteralNumericValue value: "1" @@ -33,6 +34,7 @@ - name: sample_field2 description: "This block comment is added to the property descriptions of sample_field2 and sample_field3. " type: !promise package1.uint8 + kind: COMPOSITION min_card: !new_object _type: LiteralNumericValue value: "1" @@ -42,6 +44,7 @@ - name: sample_field3 description: "This block comment is added to the property descriptions of sample_field2 and sample_field3. " type: !promise package1.uint8 + kind: COMPOSITION min_card: !new_object _type: LiteralNumericValue value: "0" @@ -51,6 +54,7 @@ - name: sample_field4 description: "This block comment is added to the property descriptions of sample_field4 and sample_field5. Fields in SampleClass can reference enums in other files. The property sample_field4 is of type SampleEnum. cf. SampleEnum " type: !promise types.SampleEnum + kind: COMPOSITION min_card: !new_object _type: LiteralNumericValue value: "1" @@ -60,6 +64,7 @@ - name: sample_field5 description: "This block comment is added to the property descriptions of sample_field4 and sample_field5. This inline comment is added to the property description of sample_field5. The property sample_field5 is of type SampleEnumValue. cf. SampleEnum, SAMPLE_ENUM_VALUE_XXX " type: !promise types.SampleEnumValue + kind: COMPOSITION min_card: !new_object _type: LiteralNumericValue value: "1" @@ -133,6 +138,7 @@ - name: status description: "The property status is of type SampleClassEnumStatus. " type: !promise types.SampleClassEnumStatus + kind: COMPOSITION min_card: !new_object _type: LiteralNumericValue value: "1" @@ -142,6 +148,7 @@ - name: color description: "The property color is of type Color. " type: !promise types.Color + kind: COMPOSITION min_card: !new_object _type: LiteralNumericValue value: "1" @@ -151,6 +158,7 @@ - name: field description: "" type: !promise package2.uint8 + kind: COMPOSITION min_card: !new_object _type: LiteralNumericValue value: "1" diff --git a/tests/test_import_msgs.py b/tests/test_import_msgs.py index 16d98a7..67d1f4b 100644 --- a/tests/test_import_msgs.py +++ b/tests/test_import_msgs.py @@ -83,6 +83,7 @@ def class_expected(): { "name": "field", "type": decl.Promise("my_package.uint8"), + "kind": "COMPOSITION", "description": "Field", "min_card": decl.NewObject( "LiteralNumericValue", value="1" @@ -178,6 +179,7 @@ def test_convert_class_with_range(importer): { "name": "field", "type": decl.Promise("my_package.uint8"), + "kind": "COMPOSITION", "description": "Field", "min_card": decl.NewObject( "LiteralNumericValue", value="1" @@ -229,6 +231,7 @@ def test_convert_class_with_ref(importer): { "name": "field", "type": decl.Promise("std_msgs.uint8"), + "kind": "COMPOSITION", "description": "Field", "min_card": decl.NewObject( "LiteralNumericValue", value="1"