From 02dc2d17be6e616fdf20bd694b373d661e6688ee Mon Sep 17 00:00:00 2001 From: huyenngn Date: Mon, 11 Mar 2024 14:36:57 +0100 Subject: [PATCH] fix: Use nested sync --- .vscode/launch.json | 4 +- capella_ros_tools/__main__.py | 2 +- capella_ros_tools/importer.py | 82 ++-- docs/source/howtos.rst | 4 +- docs/source/messages.rst | 4 +- tests/data/data_model/example_msgs.yaml | 416 +++++++++--------- .../.project | 2 +- .../.project.license | 0 .../empty_project_60.afm} | 4 +- .../empty_project_60.afm.license} | 0 .../empty_project_60.aird} | 31 +- .../empty_project_60.aird.license} | 0 .../empty_project_60.capella} | 252 +++++------ .../empty_project_60.capella.license} | 0 tests/test_import_msgs.py | 52 +-- 15 files changed, 411 insertions(+), 442 deletions(-) rename tests/data/{empty_project_52 => empty_project_60}/.project (88%) rename tests/data/{empty_project_52 => empty_project_60}/.project.license (100%) rename tests/data/{empty_project_52/empty_project_52.afm => empty_project_60/empty_project_60.afm} (54%) rename tests/data/{empty_project_52/empty_project_52.afm.license => empty_project_60/empty_project_60.afm.license} (100%) rename tests/data/{empty_project_52/empty_project_52.aird => empty_project_60/empty_project_60.aird} (59%) rename tests/data/{empty_project_52/empty_project_52.aird.license => empty_project_60/empty_project_60.aird.license} (100%) rename tests/data/{empty_project_52/empty_project_52.capella => empty_project_60/empty_project_60.capella} (59%) rename tests/data/{empty_project_52/empty_project_52.capella.license => empty_project_60/empty_project_60.capella.license} (100%) diff --git a/.vscode/launch.json b/.vscode/launch.json index 29152ba..41d117f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -41,7 +41,7 @@ "-i", "tests/data/data_model/example_msgs", "-m", - "tests/data/empty_project_52", + "tests/data/ empty_project_60", "-l", "la", "--no-deps" @@ -57,7 +57,7 @@ "-i", "git+https://github.com/DSD-DBS/dsd-ros-msg-definitions-oss", "-m", - "tests/data/empty_project_52", + "tests/data/ empty_project_60", "-l", "la" ] diff --git a/capella_ros_tools/__main__.py b/capella_ros_tools/__main__.py index f09b01f..47792b0 100644 --- a/capella_ros_tools/__main__.py +++ b/capella_ros_tools/__main__.py @@ -95,7 +95,7 @@ def import_msgs( "-o", "--output", type=click.Path(path_type=pathlib.Path, file_okay=False), - default=pathlib.Path.cwd() / "export", + default=pathlib.Path.cwd() / "data-package", help="Output directory for the .msg files.", ) def export_capella( diff --git a/capella_ros_tools/importer.py b/capella_ros_tools/importer.py index f3f3b51..8c5310b 100644 --- a/capella_ros_tools/importer.py +++ b/capella_ros_tools/importer.py @@ -65,10 +65,8 @@ def _convert_datatype(self, promise_id: str) -> dict: def _convert_package( self, - parent: decl.Promise | decl.UUIDReference, pkg_def: data_model.MessagePkgDef, - ) -> list[dict]: - instructions = [] + ) -> dict: classes = [] enums = [] packages = [] @@ -82,17 +80,17 @@ def _convert_package( for new_pkg in pkg_def.packages: promise_id = f"{pkg_def.name}.{new_pkg.name}" self._promise_ids.add(promise_id) - packages.append( - { - "promise_id": promise_id, - "find": { - "name": new_pkg.name, - }, - } - ) - instructions.extend( - self._convert_package(decl.Promise(promise_id), new_pkg) - ) + yml = { + "promise_id": promise_id, + "find": { + "name": new_pkg.name, + }, + } + + if new_sync := self._convert_package(new_pkg): + yml["sync"] = new_sync + + packages.append(yml) sync = {} if classes: @@ -102,15 +100,7 @@ def _convert_package( if packages: sync["packages"] = packages - if sync: - instructions.append( - { - "parent": parent, - "sync": sync, - } - ) - - return instructions + return sync def _convert_class( self, pkg_name: str, msg_def: data_model.MessageDef @@ -182,35 +172,33 @@ def _convert_enum(self, enum_def: data_model.EnumDef) -> dict: def to_yaml(self, layer_data_uuid: str, sa_data_uuid) -> str: """Import ROS messages into a Capella data package.""" - instructions = self._convert_package( - decl.UUIDReference(helpers.UUIDString(layer_data_uuid)), - self.messages, - ) - + instructions = [ + { + "parent": decl.UUIDReference( + helpers.UUIDString(layer_data_uuid) + ), + "sync": self._convert_package(self.messages), + } + ] if needed_types := self._promise_id_refs - self._promise_ids: datatypes = [ self._convert_datatype(promise_id) for promise_id in needed_types ] - instructions.extend( - [ - { - "parent": decl.UUIDReference( - helpers.UUIDString(sa_data_uuid) - ), - "sync": { - "packages": [ - { - "promise_id": "root.DataTypes", - "find": {"name": "Data Types"}, - } - ], - }, - }, - { - "parent": decl.Promise("root.DataTypes"), - "sync": {"datatypes": datatypes}, + instructions.append( + { + "parent": decl.UUIDReference( + helpers.UUIDString(sa_data_uuid) + ), + "sync": { + "packages": [ + { + "promise_id": "root.DataTypes", + "find": {"name": "Data Types"}, + "sync": {"datatypes": datatypes}, + } + ], }, - ] + } ) return decl.dump(instructions) diff --git a/docs/source/howtos.rst b/docs/source/howtos.rst index 6645fdd..5f2eacc 100644 --- a/docs/source/howtos.rst +++ b/docs/source/howtos.rst @@ -19,7 +19,7 @@ Import ROS2 Messages: python -m capella_ros_tools import \ -i tests/data/data_model/example_msgs \ - -m tests/data/empty_project_52 -l la \ + -m tests/data/empty_project_60 -l la \ --port=5000 --no-deps Import ROS2 Messages from Git Repository: @@ -28,7 +28,7 @@ Import ROS2 Messages from Git Repository: python -m capella_ros_tools import \ -i git+https://github.com/DSD-DBS/dsd-ros-msg-definitions-oss \ - -m tests/data/empty_project_52 -l la \ + -m tests/data/ empty_project_60 -l la \ --port=5000 Export Capella data package: diff --git a/docs/source/messages.rst b/docs/source/messages.rst index 4949ad1..c987a43 100644 --- a/docs/source/messages.rst +++ b/docs/source/messages.rst @@ -61,7 +61,7 @@ Enum definition * **Indented Comment Lines:** Comments on a line of their own but indented are added to the description of the last encountered enum literal. * **Block Comments:** Comments on a line of their own and not indented are added to the description of the next enum definition or the next enum literal definitions until an empty line and the block comment has been used. -.. literalinclude:: ../../tests/data/data_model/example_msgs/package1/msg/SampleEnum.msg +.. literalinclude:: ../../tests/data/data_model/example_msgs/package1/msg/types/SampleEnum.msg :language: python Enum and Class Definition @@ -72,7 +72,7 @@ Enum and Class Definition * Comments at the top of the file are added to the class description. * **Inline Comments:** Comments on the same line as a property or enum literal are directly added to the description of that element. * **Indented Comment Lines:** Comments on a line of their own but indented are added to the description of the last encountered property or enum literal. -* **Block Comments:** Comments on a line of their own and not indented are added to the descriptions of the next properties or added to the descriptions of the next/current enum until an empty line and the block comment has been used. +* **Block Comments:** Comments on a line of their own and not indented are added to the descriptions of the next properties, enum or enum literal until an empty line and the block comment has been used. .. code-block:: python diff --git a/tests/data/data_model/example_msgs.yaml b/tests/data/data_model/example_msgs.yaml index b052207..582a8a5 100644 --- a/tests/data/data_model/example_msgs.yaml +++ b/tests/data/data_model/example_msgs.yaml @@ -1,214 +1,210 @@ # Copyright DB InfraGO AG and contributors # SPDX-License-Identifier: Apache-2.0 -- parent: !promise root.package1 - sync: - classes: - - promise_id: package1.SampleClass - find: - name: SampleClass - set: - description: "SampleClass.msg The first comment block at the top of the file is added to the class description of SampleClass. " - properties: - - 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 - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - min_value: !new_object - _type: LiteralNumericValue - value: "0" - max_value: !new_object - _type: LiteralNumericValue - value: "10" - - name: sample_field2 - description: "This block comment is added to the property descriptions of sample_field2 and sample_field3. " - type: !promise package1.uint8 - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - - name: sample_field3 - description: "This block comment is added to the property descriptions of sample_field2 and sample_field3. " - type: !promise package1.uint8 - min_card: !new_object - _type: LiteralNumericValue - value: "0" - max_card: !new_object - _type: LiteralNumericValue - value: "*" - - 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 - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - - 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 - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - enumerations: - - promise_id: types.SampleEnumValue - find: - name: SampleEnumValue - set: - description: "SampleEnum.msg This block comment is added to the enum description of SampleEnumValue. " - literals: - - name: RED - description: "" - value: !new_object - _type: LiteralNumericValue - value: "0" - - name: BLUE - description: "This inline comment is added to the enum literal description of BLUE. " - value: !new_object - _type: LiteralNumericValue - value: "1" - - name: YELLOW - description: "This block comment is added to the enum literal descriptions of YELLOW and GREEN. " - value: !new_object - _type: LiteralNumericValue - value: "2" - - name: GREEN - description: "This block comment is added to the enum literal descriptions of YELLOW and GREEN. " - value: !new_object - _type: LiteralNumericValue - value: "3" - - promise_id: types.SampleEnum - find: - name: SampleEnum - set: - description: "This block comment is added to the enum description of SampleEnum. In a file, there can only be one or no enum whose literal names do not share a common prefix. " - literals: - - name: OK - description: "" - value: !new_object - _type: LiteralNumericValue - value: "0" - - name: WARN - description: "" - value: !new_object - _type: LiteralNumericValue - value: "1" - - name: ERROR - description: "" - value: !new_object - _type: LiteralNumericValue - value: "2" - - name: STALE - description: "" - value: !new_object - _type: LiteralNumericValue - value: "3" - -- parent: !promise root.package2 - sync: - classes: - - promise_id: package2.SampleClassEnum - find: - name: SampleClassEnum - set: - description: "SampleClassEnum.msg Properties in SampleClassEnum can reference enums in the same file. " - properties: - - name: status - description: "The property status is of type SampleClassEnumStatus. " - type: !promise types.SampleClassEnumStatus - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - - name: color - description: "The property color is of type Color. " - type: !promise types.Color - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - - name: field - description: "" - type: !promise package2.uint8 - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - enumerations: - - promise_id: types.SampleClassEnumStatus - find: - name: SampleClassEnumStatus - set: - description: "This block comment is added to the enum description of SampleClassEnumStatus. " - literals: - - name: OK - description: "" - value: !new_object - _type: LiteralNumericValue - value: "0" - - name: WARN - description: "" - value: !new_object - _type: LiteralNumericValue - value: "1" - - name: ERROR - description: "" - value: !new_object - _type: LiteralNumericValue - value: "2" - - name: STALE - description: "" - value: !new_object - _type: LiteralNumericValue - value: "3" - - promise_id: types.Color - find: - name: Color - set: - description: "This block comment is added to the enum description of Color. " - literals: - - name: RED - description: "" - value: !new_object - _type: LiteralNumericValue - value: "0" - - name: BLUE - description: "" - value: !new_object - _type: LiteralNumericValue - value: "1" - - name: YELLOW - description: "" - value: !new_object - _type: LiteralNumericValue - value: "2" - - parent: !uuid "00000000-0000-0000-0000-000000000000" sync: packages: - promise_id: root.package1 find: name: package1 + sync: + classes: + - promise_id: package1.SampleClass + find: + name: SampleClass + set: + description: "SampleClass.msg The first comment block at the top of the file is added to the class description of SampleClass. " + properties: + - 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 + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + min_value: !new_object + _type: LiteralNumericValue + value: "0" + max_value: !new_object + _type: LiteralNumericValue + value: "10" + - name: sample_field2 + description: "This block comment is added to the property descriptions of sample_field2 and sample_field3. " + type: !promise package1.uint8 + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + - name: sample_field3 + description: "This block comment is added to the property descriptions of sample_field2 and sample_field3. " + type: !promise package1.uint8 + min_card: !new_object + _type: LiteralNumericValue + value: "0" + max_card: !new_object + _type: LiteralNumericValue + value: "*" + - 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 + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + - 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 + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + enumerations: + - promise_id: types.SampleEnumValue + find: + name: SampleEnumValue + set: + description: "SampleEnum.msg This block comment is added to the enum description of SampleEnumValue. " + literals: + - name: RED + description: "" + value: !new_object + _type: LiteralNumericValue + value: "0" + - name: BLUE + description: "This inline comment is added to the enum literal description of BLUE. " + value: !new_object + _type: LiteralNumericValue + value: "1" + - name: YELLOW + description: "This block comment is added to the enum literal descriptions of YELLOW and GREEN. " + value: !new_object + _type: LiteralNumericValue + value: "2" + - name: GREEN + description: "This block comment is added to the enum literal descriptions of YELLOW and GREEN. " + value: !new_object + _type: LiteralNumericValue + value: "3" + - promise_id: types.SampleEnum + find: + name: SampleEnum + set: + description: "This block comment is added to the enum description of SampleEnum. In a file, there can only be one or no enum whose literal names do not share a common prefix. " + literals: + - name: OK + description: "" + value: !new_object + _type: LiteralNumericValue + value: "0" + - name: WARN + description: "" + value: !new_object + _type: LiteralNumericValue + value: "1" + - name: ERROR + description: "" + value: !new_object + _type: LiteralNumericValue + value: "2" + - name: STALE + description: "" + value: !new_object + _type: LiteralNumericValue + value: "3" - promise_id: root.package2 find: name: package2 + sync: + classes: + - promise_id: package2.SampleClassEnum + find: + name: SampleClassEnum + set: + description: "SampleClassEnum.msg Properties in SampleClassEnum can reference enums in the same file. " + properties: + - name: status + description: "The property status is of type SampleClassEnumStatus. " + type: !promise types.SampleClassEnumStatus + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + - name: color + description: "The property color is of type Color. " + type: !promise types.Color + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + - name: field + description: "" + type: !promise package2.uint8 + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + enumerations: + - promise_id: types.SampleClassEnumStatus + find: + name: SampleClassEnumStatus + set: + description: "This block comment is added to the enum description of SampleClassEnumStatus. " + literals: + - name: OK + description: "" + value: !new_object + _type: LiteralNumericValue + value: "0" + - name: WARN + description: "" + value: !new_object + _type: LiteralNumericValue + value: "1" + - name: ERROR + description: "" + value: !new_object + _type: LiteralNumericValue + value: "2" + - name: STALE + description: "" + value: !new_object + _type: LiteralNumericValue + value: "3" + - promise_id: types.Color + find: + name: Color + set: + description: "This block comment is added to the enum description of Color. " + literals: + - name: RED + description: "" + value: !new_object + _type: LiteralNumericValue + value: "0" + - name: BLUE + description: "" + value: !new_object + _type: LiteralNumericValue + value: "1" + - name: YELLOW + description: "" + value: !new_object + _type: LiteralNumericValue + value: "2" - parent: !uuid "00000000-0000-0000-0000-000000000001" sync: @@ -216,15 +212,13 @@ - promise_id: root.DataTypes find: name: "Data Types" - -- parent: !promise root.DataTypes - sync: - datatypes: - - promise_id: package1.uint8 - find: - name: uint8 - _type: NumericType - - promise_id: package2.uint8 - find: - name: uint8 - _type: NumericType + sync: + datatypes: + - promise_id: package1.uint8 + find: + name: uint8 + _type: NumericType + - promise_id: package2.uint8 + find: + name: uint8 + _type: NumericType diff --git a/tests/data/empty_project_52/.project b/tests/data/empty_project_60/.project similarity index 88% rename from tests/data/empty_project_52/.project rename to tests/data/empty_project_60/.project index 5315043..4931a0e 100644 --- a/tests/data/empty_project_52/.project +++ b/tests/data/empty_project_60/.project @@ -1,6 +1,6 @@ - empty_project_52 + empty_project_60 diff --git a/tests/data/empty_project_52/.project.license b/tests/data/empty_project_60/.project.license similarity index 100% rename from tests/data/empty_project_52/.project.license rename to tests/data/empty_project_60/.project.license diff --git a/tests/data/empty_project_52/empty_project_52.afm b/tests/data/empty_project_60/empty_project_60.afm similarity index 54% rename from tests/data/empty_project_52/empty_project_52.afm rename to tests/data/empty_project_60/empty_project_60.afm index 33d102e..fe47ab6 100644 --- a/tests/data/empty_project_52/empty_project_52.afm +++ b/tests/data/empty_project_60/empty_project_60.afm @@ -1,4 +1,4 @@ - - + + diff --git a/tests/data/empty_project_52/empty_project_52.afm.license b/tests/data/empty_project_60/empty_project_60.afm.license similarity index 100% rename from tests/data/empty_project_52/empty_project_52.afm.license rename to tests/data/empty_project_60/empty_project_60.afm.license diff --git a/tests/data/empty_project_52/empty_project_52.aird b/tests/data/empty_project_60/empty_project_60.aird similarity index 59% rename from tests/data/empty_project_52/empty_project_52.aird rename to tests/data/empty_project_60/empty_project_60.aird index 63f8ae5..e156dda 100644 --- a/tests/data/empty_project_52/empty_project_52.aird +++ b/tests/data/empty_project_60/empty_project_60.aird @@ -1,29 +1,26 @@ - - empty_project_52.afm - empty_project_52.capella - + + empty_project_60.afm + empty_project_60.capella + - + - - + + - - + + - + - - - - - - - + + + + diff --git a/tests/data/empty_project_52/empty_project_52.aird.license b/tests/data/empty_project_60/empty_project_60.aird.license similarity index 100% rename from tests/data/empty_project_52/empty_project_52.aird.license rename to tests/data/empty_project_60/empty_project_60.aird.license diff --git a/tests/data/empty_project_52/empty_project_52.capella b/tests/data/empty_project_60/empty_project_60.capella similarity index 59% rename from tests/data/empty_project_52/empty_project_52.capella rename to tests/data/empty_project_60/empty_project_60.capella index 836b9e3..cff913f 100644 --- a/tests/data/empty_project_52/empty_project_52.capella +++ b/tests/data/empty_project_60/empty_project_60.capella @@ -1,272 +1,272 @@ - + - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:libraries="http://www.polarsys.org/capella/common/libraries/6.0.0" + xmlns:org.polarsys.capella.core.data.capellacommon="http://www.polarsys.org/capella/core/common/6.0.0" + xmlns:org.polarsys.capella.core.data.capellacore="http://www.polarsys.org/capella/core/core/6.0.0" + xmlns:org.polarsys.capella.core.data.capellamodeller="http://www.polarsys.org/capella/core/modeller/6.0.0" + xmlns:org.polarsys.capella.core.data.cs="http://www.polarsys.org/capella/core/cs/6.0.0" + xmlns:org.polarsys.capella.core.data.ctx="http://www.polarsys.org/capella/core/ctx/6.0.0" + xmlns:org.polarsys.capella.core.data.epbs="http://www.polarsys.org/capella/core/epbs/6.0.0" + xmlns:org.polarsys.capella.core.data.fa="http://www.polarsys.org/capella/core/fa/6.0.0" + xmlns:org.polarsys.capella.core.data.information="http://www.polarsys.org/capella/core/information/6.0.0" + xmlns:org.polarsys.capella.core.data.information.datatype="http://www.polarsys.org/capella/core/information/datatype/6.0.0" + xmlns:org.polarsys.capella.core.data.information.datavalue="http://www.polarsys.org/capella/core/information/datavalue/6.0.0" + xmlns:org.polarsys.capella.core.data.la="http://www.polarsys.org/capella/core/la/6.0.0" + xmlns:org.polarsys.capella.core.data.oa="http://www.polarsys.org/capella/core/oa/6.0.0" + xmlns:org.polarsys.capella.core.data.pa="http://www.polarsys.org/capella/core/pa/6.0.0" + id="954dcd44-8942-4f2f-bd56-c7aa1c423ddd" + name="empty_project_60"> + + id="99c1bd6f-0e94-475c-b99d-fb05a8d47099" name="ProgressStatus"> + id="14cbdafc-4cef-45f1-b42d-4a828e9cc404" name="DRAFT"/> + id="876c2b6c-11f9-4006-b6ea-716e45716fcf" name="TO_BE_REVIEWED"/> + id="29838cbd-892f-4c2a-bee5-69127d877401" name="TO_BE_DISCUSSED"/> + id="c9b3fd06-06ac-4a54-b072-f6b02e2050da" name="REWORK_NECESSARY"/> + id="21825414-7a7a-496f-847a-c18a2b094def" name="UNDER_REWORK"/> + id="5ef18b4c-3389-4fb2-8ea7-4a6c9b082b28" name="REVIEWED_OK"/> - + id="a20452cc-e1b0-40f3-b6e8-662f14663cb9" name="empty_project_60"> + id="b4382876-58d1-4317-8104-462bffd1597e" name="Operational Analysis"> + id="0f849976-e18e-466f-8f95-13f11fc4e506" name="Operational Activities"> + id="d30c824e-4d8a-47ba-bee4-51156cde2b76" name="Root Operational Activity"/> + id="b9042059-a0fd-458c-b485-d2022dcba289" name="Operational Capabilities"/> + id="4398a213-78f4-492c-ae2f-96186d30acdd" name="Interfaces"/> - + - + id="fab15140-74e2-47ec-b3a1-ef22c32db236" name="System Analysis"> + id="2b3f21aa-ab4f-4476-92f9-d13d88a90106" name="System Functions"> + id="6278ee6b-980e-4685-be3b-58ce0a9b7e37" name="Root System Function"> + id="d569158e-2c85-429d-a7fa-3347eb41508a" targetElement="#d30c824e-4d8a-47ba-bee4-51156cde2b76" + sourceElement="#6278ee6b-980e-4685-be3b-58ce0a9b7e37"/> + id="8b0eeb8b-e790-4f86-831b-cb50248161ac" name="Capabilities"/> + id="2c0e8d8a-f202-49c3-b231-ddc6bd05e742" name="Interfaces"/> + id="5ea4f364-2f04-496f-946e-b424cd37d57a" name="Data"> + id="e477737d-1767-477c-abd5-1a81f2fd2f91" name="Predefined Types"> + id="3e23d67d-086b-43b6-9e57-c767a87a29bb" name="Boolean" visibility="PUBLIC"> + id="5ad2fc24-680f-4986-b1e8-e7e4327fc17b" name="False" abstractType="#3e23d67d-086b-43b6-9e57-c767a87a29bb"/> + id="a8066cb5-4ac3-422f-86c1-a149da44d9dc" name="Byte" visibility="PUBLIC"> + id="73678598-71ef-450b-b33f-6f9284ce7fc5" name="Char" visibility="PUBLIC"> + id="bed78246-063d-443c-9f06-efa3cbb0e58b" name="Hexadecimal" visibility="PUBLIC"> + id="8721583e-32d0-459f-9649-a5df5e8050b0" operator="POW"> + id="4eeee524-ff02-4ba2-b2c9-9bdf6fd0e180" value="2"/> + id="5cef2f7c-71f5-4711-a696-aacad7f27e64" value="64"/> + id="43875e99-5ed4-42de-a36b-fc5c517e8a16" value="1"/> + id="a59a8f2c-330b-4597-9b95-d5518f163325" name="Integer" visibility="PUBLIC"/> + id="706e33fa-c1a7-467d-995f-bf24a4284c5d" name="Long" visibility="PUBLIC"/> + id="73d1d9ee-1936-4c65-b176-becea3922754" name="LongLong" visibility="PUBLIC"/> + id="6172dc17-e7a8-4f9d-b500-727dc52c65c0" name="Short" visibility="PUBLIC"/> + id="339f6446-98a6-4d99-817a-b39e7d9371a0" name="String" visibility="PUBLIC"/> - + id="9e384278-3a6c-4a93-881a-bd7ac6f4e51d" name="Structure"> + + id="aba557bb-7804-42c9-bbfc-a8990b20c152" name="System"> + id="1a907c03-c945-4403-b90d-bc714bd22a0a" name="System State Machine"> + id="f4980352-f195-4caa-9d78-4dfd23487a57" name="Default Region"/> - + id="c0906321-59da-4a9b-bae4-dca920cb6f4a" targetElement="#b4382876-58d1-4317-8104-462bffd1597e" + sourceElement="#fab15140-74e2-47ec-b3a1-ef22c32db236"/> + id="744121d2-ad26-4108-bba0-245c179ff49c" name="Logical Architecture"> + id="f3ed3edf-b562-4b4b-9010-3c17a9c1a7fd" name="Logical Functions"> + id="da762d68-2c41-4f75-adb7-e436916ddbd5" name="Root Logical Function"> + id="6cfc7cc5-2d09-4fd9-971a-f713562060e3" targetElement="#6278ee6b-980e-4685-be3b-58ce0a9b7e37" + sourceElement="#da762d68-2c41-4f75-adb7-e436916ddbd5"/> + id="c448ec5c-da05-4d49-a403-39bea7b0927c" name="Capabilities"/> + id="bf2721ca-4197-4fe7-a8e5-77ea7c9ce9f8" name="Interfaces"/> + id="03e7ba96-68f5-4c7f-85ed-8932b65f53a7" name="Data"/> - + id="848102a1-e340-460c-a20a-545379c15e1c" name="Structure"> + + id="1bc48e6b-588e-4a71-802f-8156e2ad4537" name="Logical System"> + id="d3241da7-c81f-4c87-974d-85e98919a174" targetElement="#aba557bb-7804-42c9-bbfc-a8990b20c152" + sourceElement="#1bc48e6b-588e-4a71-802f-8156e2ad4537"/> + id="d72ff7c3-d758-4db5-93b5-64eeebe7f726" targetElement="#fab15140-74e2-47ec-b3a1-ef22c32db236" + sourceElement="#744121d2-ad26-4108-bba0-245c179ff49c"/> + id="b5a6ef0b-ac77-4759-8207-890c2bee5e7e" name="Physical Architecture"> + id="67caae0d-6106-4e9c-a156-9c3f5d842a7a" name="Physical Functions"> + id="1cbc810c-566c-4d1d-b490-0c4ac458e93f" name="Root Physical Function"> + id="e0339507-d320-48db-923f-934c4c791ac6" targetElement="#da762d68-2c41-4f75-adb7-e436916ddbd5" + sourceElement="#1cbc810c-566c-4d1d-b490-0c4ac458e93f"/> + id="80378634-2561-4f94-8118-63d5c3622dcb" name="Capabilities"/> + id="43bd09c3-0162-486f-9383-486bfffe9f05" name="Interfaces"/> + id="6972425c-2312-4c00-a93e-e0aac30a176f" name="Data"/> - + id="5073ff73-35e2-4ce5-9885-45357744c9ae" name="Structure"> + + id="81a575b3-2944-4c33-832a-a23699f795f3" name="Physical System"> + id="e0eb794f-8c58-48dd-95b3-eabc73685e6f" targetElement="#1bc48e6b-588e-4a71-802f-8156e2ad4537" + sourceElement="#81a575b3-2944-4c33-832a-a23699f795f3"/> + id="fe5f64f4-ac88-4c9b-98da-82d88f8c47c8" targetElement="#744121d2-ad26-4108-bba0-245c179ff49c" + sourceElement="#b5a6ef0b-ac77-4759-8207-890c2bee5e7e"/> + id="d9ea2aef-ae27-4536-a416-647ca984248c" name="EPBS Architecture"> + id="f9a48c69-3d09-415a-bb4d-b0767a29a8d2" name="Capabilities"/> - + id="68e128c3-a56d-4261-9c17-e9c83e82fdf9" name="Structure"> + + id="4c0a9ac2-52a0-48b0-95c7-6fc51cd4a55e" name="System" kind="SystemCI"> + id="7f256267-9f64-430e-acdd-88ddc40185e8" targetElement="#81a575b3-2944-4c33-832a-a23699f795f3" + sourceElement="#4c0a9ac2-52a0-48b0-95c7-6fc51cd4a55e"/> + id="c0fd751c-f9af-4136-af90-66122eff3a40" targetElement="#b5a6ef0b-ac77-4759-8207-890c2bee5e7e" + sourceElement="#d9ea2aef-ae27-4536-a416-647ca984248c"/> diff --git a/tests/data/empty_project_52/empty_project_52.capella.license b/tests/data/empty_project_60/empty_project_60.capella.license similarity index 100% rename from tests/data/empty_project_52/empty_project_52.capella.license rename to tests/data/empty_project_60/empty_project_60.capella.license diff --git a/tests/test_import_msgs.py b/tests/test_import_msgs.py index f0d72f9..16d98a7 100644 --- a/tests/test_import_msgs.py +++ b/tests/test_import_msgs.py @@ -21,7 +21,7 @@ SAMPLE_PACKAGE_PATH = PATH.joinpath("data/data_model/example_msgs") SAMPLE_PACKAGE_YAML = PATH.joinpath("data/data_model/example_msgs.yaml") -DUMMY_PATH = PATH.joinpath("data/empty_project_52") +DUMMY_PATH = PATH.joinpath("data/empty_project_60") ROOT = helpers.UUIDString("00000000-0000-0000-0000-000000000000") SA_ROOT = helpers.UUIDString("00000000-0000-0000-0000-000000000001") @@ -274,39 +274,29 @@ def test_convert_package( packages=[subpkg_def, subpkg2_def], ) - expected = [ - { - "parent": decl.Promise("my_package.sub_package"), - "sync": { - "enumerations": [enum_expected], + expected = { + "classes": [class_expected], + "packages": [ + { + "promise_id": "my_package.sub_package", + "find": { + "name": "sub_package", + }, + "sync": { + "enumerations": [enum_expected], + }, }, - }, - { - "parent": decl.Promise("root.my_package"), - "sync": { - "classes": [class_expected], - "packages": [ - { - "promise_id": "my_package.sub_package", - "find": { - "name": "sub_package", - }, - }, - { - "promise_id": "my_package.sub_package2", - "find": { - "name": "sub_package2", - }, - }, - ], + { + "promise_id": "my_package.sub_package2", + "find": { + "name": "sub_package2", + }, }, - }, - ] + ], + } - actual = importer._convert_package( - decl.Promise("root.my_package"), pkg_def - ) - assert decl.dump(actual) == decl.dump(expected) + actual = importer._convert_package(pkg_def) + assert decl.dump([actual]) == decl.dump([expected]) def test_import_msgs():