Skip to content

Commit

Permalink
fix: Add kind to props
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed Mar 12, 2024
1 parent ba2f429 commit 9179d6e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 1 addition & 3 deletions capella_ros_tools/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ def _convert_package(
enums.append(self._convert_enum(enum_def))

for new_pkg in pkg_def.packages:
promise_id = f"{pkg_def.name}.{new_pkg.name}"
self._promise_ids.add(promise_id)
yml = {
"promise_id": promise_id,
"find": {
"name": new_pkg.name,
},
Expand Down Expand Up @@ -111,6 +108,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
Expand Down
14 changes: 10 additions & 4 deletions tests/data/data_model/example_msgs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
- parent: !uuid "00000000-0000-0000-0000-000000000000"
sync:
packages:
- promise_id: root.package1
find:
- find:
name: package1
sync:
classes:
Expand All @@ -18,6 +17,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"
Expand All @@ -33,6 +33,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"
Expand All @@ -42,6 +43,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"
Expand All @@ -51,6 +53,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"
Expand All @@ -60,6 +63,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"
Expand Down Expand Up @@ -119,8 +123,7 @@
value: !new_object
_type: LiteralNumericValue
value: "3"
- promise_id: root.package2
find:
- find:
name: package2
sync:
classes:
Expand All @@ -133,6 +136,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"
Expand All @@ -142,6 +146,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"
Expand All @@ -151,6 +156,7 @@
- name: field
description: ""
type: !promise package2.uint8
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "1"
Expand Down
5 changes: 3 additions & 2 deletions tests/test_import_msgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -278,7 +281,6 @@ def test_convert_package(
"classes": [class_expected],
"packages": [
{
"promise_id": "my_package.sub_package",
"find": {
"name": "sub_package",
},
Expand All @@ -287,7 +289,6 @@ def test_convert_package(
},
},
{
"promise_id": "my_package.sub_package2",
"find": {
"name": "sub_package2",
},
Expand Down

0 comments on commit 9179d6e

Please sign in to comment.