From add59adfb1ac4eb8315dbd6660a0806d6b0a9205 Mon Sep 17 00:00:00 2001 From: ewuerger Date: Tue, 7 Feb 2023 15:47:42 +0100 Subject: [PATCH 1/2] fix: Update snapshot schema and test snapshots --- capella_rm_bridge/auditing.py | 1 + capella_rm_bridge/changeset/actiontypes.py | 11 + .../changeset/snapshot_input.schema.json | 265 +++++++++++------- docs/source/snapshot.rst | 11 +- tests/data/snapshots/snapshot.yaml | 141 +++++----- tests/data/snapshots/snapshot1.yaml | 154 +++++----- tests/data/snapshots/snapshot2.yaml | 77 ++--- tests/test_changeset.py | 62 ++-- 8 files changed, 419 insertions(+), 303 deletions(-) diff --git a/capella_rm_bridge/auditing.py b/capella_rm_bridge/auditing.py index 25c6c16..8647531 100644 --- a/capella_rm_bridge/auditing.py +++ b/capella_rm_bridge/auditing.py @@ -115,6 +115,7 @@ class ChangeAuditor: attribute="allocated_functions", element="", uuid="f28ec0f8-f3b3-43a0-8af7-79f194b29a2d", + ), Deletion( parent="0d2edb8f-fa34-4e73-89ec-fb9a63001440", attribute="components", diff --git a/capella_rm_bridge/changeset/actiontypes.py b/capella_rm_bridge/changeset/actiontypes.py index 2d54ca4..7c1cb7a 100644 --- a/capella_rm_bridge/changeset/actiontypes.py +++ b/capella_rm_bridge/changeset/actiontypes.py @@ -45,6 +45,12 @@ class WorkItem(te.TypedDict, total=False): children: cabc.Sequence[WorkItem] +class MetaData(te.TypedDict): + tool: str + revision: str + connector: str + + class TrackerSnapshot(te.TypedDict): id: int version: int | float @@ -53,6 +59,11 @@ class TrackerSnapshot(te.TypedDict): items: cabc.Sequence[WorkItem] +class Snapshot(te.TypedDict): + metadata: MetaData + modules: cabc.Sequence[TrackerSnapshot] + + class AttributeDefinition(te.TypedDict): type: str diff --git a/capella_rm_bridge/changeset/snapshot_input.schema.json b/capella_rm_bridge/changeset/snapshot_input.schema.json index 122cef1..9cb50ee 100644 --- a/capella_rm_bridge/changeset/snapshot_input.schema.json +++ b/capella_rm_bridge/changeset/snapshot_input.schema.json @@ -1,120 +1,189 @@ { - "$id": "https://dsd-dbs.github.io/rm-bridge/importer/snapshot.schema.json", + "$id": "https://dsd-dbs.github.io/capella-rm-bridge/importer/snapshot.schema.json", "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "RM-Bridge Importer Snapshot", + "title": "Capella RM-Bridge Importer Snapshot", "description": "A downloaded snapshot of Requirements Modules from an external Requirements Management tool.", - "type": "array", - "items": { - "$ref": "#/$defs/requirements-module" - }, - "minItems": 1, - "uniqueItems": true, - "$defs": { - "requirements-module": { - "description": "Representation of a RequirementsModule in Capella, taken from the external RM tool. Some tools might use different terminology for the same concept (like \"Tracker\", etc.)", + "type": "object", + "properties": { + "metadata": { + "description": "Metadata of all components that created this snapshot. This includes version info and revision hashes/numbers of content.", "type": "object", - "required": [ - "id" - ], - "additionalProperties": false, "properties": { - "id": { - "description": "The unique identifier of this module in the external RM tool.", + "tool": { + "description": "Version of the used RM Tool.", "type": "string" }, - "attributes": { - "description": "AttributeDefinitions for all possible attributes that Requirements or RequirementsFolders in a module could have. Not all of these definitions need to be actually used by any of the requirements' AttributeValues.", + "revision": { + "description": "Revision of the content managed by the RM Tool.", + "type": "string" + }, + "connector": { + "description": "Version of the used software for connecting/bridging the RM Tool with Capella.", + "type": "string" + } + }, + "required": [ + "tool", + "revision", + "connector" + ] + }, + "modules": { + "type": "array", + "items": { + "$ref": "#/properties/modules/$defs/requirements-module" + }, + "minItems": 1, + "uniqueItems": true, + "$defs": { + "requirements-module": { + "description": "Representation of a RequirementsModule in Capella, taken from the external RM tool. Some tools might use different terminology for the same concept (like \"Tracker\", etc.)", "type": "object", - "patternProperties": { - ".": { + "required": [ + "id" + ], + "additionalProperties": false, + "properties": { + "id": { + "description": "The unique identifier of this module in the external RM tool.", + "type": "string" + }, + "long_name": { + "description": "Value of the \"Long Name\" field in Capella. Here it is the long name of the CapellaModule.", + "type": "string" + }, + "data_types": { + "description": "EnumerationDataTypeDefinition for all EnumerationAttributeDefinitions used by EnumAttributeValues. Not all of these definitions need to be actually used by any of the requirements' EnumAttributeValues.", "type": "object", - "oneOf": [ - { - "properties": { - "type": { - "type": "string", - "enum": [ - "Boolean", - "Date", - "Float", - "Integer", - "String" - ] - } - }, - "additionalProperties": false - }, - { + "additionalProperties": false, + "patternProperties": { + ".": { + "description": "The values that are available for this EnumerationDataTypeDefinition. They are sometimes called \"options\"", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "requirement_types": { + "description": "All RequirementTypes whose Requirements can be assigned to. These are for managing availability of values and data-types for all AttributeValues via AttributeDefinitions.", + "type": "object", + "additionalProperties": false, + "patternProperties": { + ".": { + "description": "The RequirementType that are available for all Requirements to be assigned to.", + "type": "object", + "additionalProperties": false, + "required": [ + "long_name" + ], "properties": { - "type": { - "type": "string", - "const": "Enum" + "long_name": { + "description": "Value of the \"Long Name\" field in Capella. Here it is the long name of the RequirementType.", + "type": "string" }, - "values": { - "description": "The values that this Enum Attribute can have.", - "type": "array", - "items": { - "type": "string" + "attributes": { + "description": "AttributeDefinitions for all possible attributes that Requirements or RequirementsFolders in a module could have. Not all of these definitions need to be actually used by any of the requirements' AttributeValues.", + "type": "object", + "patternProperties": { + ".": { + "description": "The \"Long Name\" of the AttributeDefinition.", + "type": "object", + "oneOf": [ + { + "properties": { + "type": { + "type": "string", + "enum": [ + "Boolean", + "Date", + "Float", + "Integer", + "String" + ] + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "type": "string", + "const": "Enum" + }, + "multi_values": { + "description": "Whether the Enum Attribute can have multiple values (true) or must always have exactly one value (false).", + "type": "boolean" + } + }, + "additionalProperties": false + } + ] + } } - }, - "multi_values": { - "description": "Whether the Enum Attribute can have multiple values (true) or must always have exactly one value (false).", - "type": "boolean" } - }, - "additionalProperties": false + } } - ] + } + }, + "items": { + "description": "The Requirements or RequirementsFolders in this module, ordered in a hierarchical manner. Some tools might use different terminology for the same concept, like \"work item\".", + "type": "array", + "items": { + "$ref": "#/properties/modules/$defs/requirement" + } } } }, - "items": { - "description": "The Requirements or RequirementsFolders in this module, ordered in a hierarchical manner. Some tools might use different terminology for the same concept, like \"work item\".", - "type": "array", - "items": { - "$ref": "#/$defs/requirement" - } - } - } - }, - "requirement": { - "description": "A Requirement or RequirementsFolder in the external Requirements Management tool. Some tools might use different terminology for the same concept, like \"work item\".", - "type": "object", - "required": [ - "id", - "long_name" - ], - "properties": { - "id": { - "description": "Unique identifier of this Requirement in the external RM tool", - "type": "string" - }, - "long_name": { - "description": "Value of the \"Long Name\" field in Capella. Usually a short summary of the Requirement's \"text\".", - "type": "string" - }, - "text": { - "description": "Complete description text of the requirement as HTML.", - "type": "string" - }, - "attributes": { - "description": "Values for the attributes defined at module level. Not all attributes defined in the Module's `attributes` need to be present on any Requirement. However, it is not allowed for a Requirement to have attributes which do not also appear in the Module's `attributes`.\n\nFurthermore, the value of each Requirement attribute must match what is defined on the Module level:\n\n- For Boolean, Float, Integer and String, use the respective YAML types\n- For Date, use the date/time YAML type, including the timezone if possible\n- For Enum, use either a string that is equal to one of the Enum's members, or a list of such strings for multi-valued enums", + "requirement": { + "description": "A Requirement or RequirementsFolder in the external Requirements Management tool. Some tools might use different terminology for the same concept, like \"work item\".", "type": "object", - "patternProperties": { - ".": { - "description": "The value for this Requirement attribute (see the description of the `attributes` object for which types are valid)." + "required": [ + "id", + "long_name" + ], + "properties": { + "id": { + "description": "Unique identifier of this Requirement in the external RM tool", + "type": "string" + }, + "long_name": { + "description": "Value of the \"Long Name\" field in Capella. Usually a short summary of the Requirement's \"text\".", + "type": "string" + }, + "type": { + "description": "The assigned RequirementType. This value needs to be defined in the \"requirement_types\" object.", + "type": "string" + }, + "text": { + "description": "Complete description text of the requirement as HTML.", + "type": "string" + }, + "attributes": { + "description": "Values for the attributes defined at module level. Not all attributes defined in the Module's `attributes` need to be present on any Requirement. However, it is not allowed for a Requirement to have attributes which do not also appear in the Module's `attributes`.\n\nFurthermore, the value of each Requirement attribute must match what is defined on the Module level:\n\n- For Boolean, Float, Integer and String, use the respective YAML types\n- For Date, use the date/time YAML type, including the timezone if possible\n- For Enum, use either a string that is equal to one of the Enum's members, or a list of such strings for multi-valued enums", + "type": "object", + "patternProperties": { + ".": { + "description": "The value for this Requirement attribute (see the description of the `attributes` object for which types are valid)." + } + } + }, + "children": { + "description": "Requirements or RequirementsFolders underneath a RequirementsFolder (see description of the `items` object). If the `children` property exists, the object is recognized as a folder, as in Capella, Requirements can only be created under RequirementsModules or RequirementsFolders.", + "type": "array", + "items": { + "$ref": "#/properties/modules/$defs/requirement" + } } - } - }, - "children": { - "description": "Requirements or RequirementsFolders underneath a RequirementsFolder (see description of the `items` object). If the `children` property exists, the object is recognized as a folder, as in Capella, Requirements can only be created under RequirementsModules or RequirementsFolders.", - "type": "array", - "items": { - "$ref": "#/$defs/requirement" - } + }, + "additionalProperties": false } - }, - "additionalProperties": false + } } - } + }, + "required": [ + "metadata", + "modules" + ] } diff --git a/docs/source/snapshot.rst b/docs/source/snapshot.rst index 8a8087f..e3413be 100644 --- a/docs/source/snapshot.rst +++ b/docs/source/snapshot.rst @@ -9,8 +9,10 @@ Snapshot ******** The snapshot is the input needed for calculating the -:ref:`ChangeSet` and is a list of modules. Each module will be -compared against a matching +:ref:`ChangeSet`. It consists of a metadata section and a list of +modules. The metadata documents the versions of the used RM tool and its +connector, the revision of the RM content and the Each module will be compared +against a matching :external:class:`~capellambse.extensions.reqif.CapellaModule` from the given model. If no matching ``CapellaModule`` was found this module will be skipped. Differences of the module snapshot and the model ``CapellaModule`` will result @@ -24,6 +26,11 @@ As previously noted: A module (or tracker) in the given snapshot equals a .. code-block:: yaml + metadata: + tool: RM Tool Version + revision: r1234 + connector: RM-Bridge-Polarion vX.Y.Z + modules: - id: MODULE-000 # mandatory long_name: Example # optional diff --git a/tests/data/snapshots/snapshot.yaml b/tests/data/snapshots/snapshot.yaml index 1bf9270..c0b8664 100644 --- a/tests/data/snapshots/snapshot.yaml +++ b/tests/data/snapshots/snapshot.yaml @@ -1,75 +1,80 @@ # SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-rm-bridge contributors # SPDX-License-Identifier: Apache-2.0 -# yaml-language-server: $schema=../../../rm_bridge/changeset/snapshot_input.schema.json -- id: project/space/example title - long_name: example title - data_types: # Enumeration Data Type Definitions - Type: - - Unset - - Folder - - Functional - Release: - - Feature Rel. 1 - - Feature Rel. 2 +# yaml-language-server: $schema=../../../capella_rm_bridge/changeset/snapshot_input.schema.json +metadata: + tool: RM Tool Version + revision: r1234 + connector: RM-Bridge-Polarion vX.Y.Z +modules: + - id: project/space/example title + long_name: example title + data_types: # Enumeration Data Type Definitions + Type: + - Unset + - Folder + - Functional + Release: + - Feature Rel. 1 + - Feature Rel. 2 - requirement_types: # WorkItemTypes - system_requirement: - long_name: System Requirement - attributes: # Field Definitions, we don't need the IDs - Capella ID: # Field name - type: String # -> AttributeDefinition - Type: - type: Enum - Submitted at: - type: Date # -> AttributeDefinition - Release: - type: Enum - multi_values: true - software_requirement: - long_name: Software Requirement - attributes: - Capella ID: - type: String - Type: - type: Enum - Submitted at: - type: Date - stakeholder_requirement: - long_name: Stakeholder Requirement - attributes: - Capella ID: - type: String + requirement_types: # WorkItemTypes + system_requirement: + long_name: System Requirement + attributes: # Field Definitions, we don't need the IDs + Capella ID: # Field name + type: String # -> AttributeDefinition + Type: + type: Enum + Submitted at: + type: Date # -> AttributeDefinition + Release: + type: Enum + multi_values: true + software_requirement: + long_name: Software Requirement + attributes: + Capella ID: + type: String + Type: + type: Enum + Submitted at: + type: Date + stakeholder_requirement: + long_name: Stakeholder Requirement + attributes: + Capella ID: + type: String - items: # WorkItems - - id: REQ-001 - long_name: Functional Requirements - text:

Test Description

- type: system_requirement # WorkItemType ID NOT name + items: # WorkItems + - id: REQ-001 + long_name: Functional Requirements + text:

Test Description

+ type: system_requirement # WorkItemType ID NOT name - attributes: - Type: [Folder] # artifact from CODEBEAMER and cleaned in RM Bridge + attributes: + Type: [Folder] # artifact from CODEBEAMER and cleaned in RM Bridge - children: # Folder b/c non-empty children - - id: REQ-002 - long_name: Function Requirement - text: ... - type: system_requirement - attributes: # Fields - Capella ID: R-FNC-00001 # name, value pair - Type: [Functional] # values in a list for enum fields - Release: - - Feature Rel. 1 - - Feature Rel. 2 - Submitted at: 2022-06-30 17:07:18.664000+02:00 # datetime.datetime for dates - - id: REQ-003 - long_name: Kinds - type: software_requirement - attributes: - Type: [Folder] - children: - - id: REQ-004 - long_name: Kind Requirement - type: stakeholder_requirement - attributes: - Capella ID: R-FNC-00002 + children: # Folder b/c non-empty children + - id: REQ-002 + long_name: Function Requirement + text: ... + type: system_requirement + attributes: # Fields + Capella ID: R-FNC-00001 # name, value pair + Type: [Functional] # values in a list for enum fields + Release: + - Feature Rel. 1 + - Feature Rel. 2 + Submitted at: 2022-06-30 17:07:18.664000+02:00 # datetime.datetime for dates + - id: REQ-003 + long_name: Kinds + type: software_requirement + attributes: + Type: [Folder] + children: + - id: REQ-004 + long_name: Kind Requirement + type: stakeholder_requirement + attributes: + Capella ID: R-FNC-00002 diff --git a/tests/data/snapshots/snapshot1.yaml b/tests/data/snapshots/snapshot1.yaml index 680594d..263a3f8 100644 --- a/tests/data/snapshots/snapshot1.yaml +++ b/tests/data/snapshots/snapshot1.yaml @@ -1,79 +1,81 @@ # SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-rm-bridge contributors # SPDX-License-Identifier: Apache-2.0 -# yaml-language-server: $schema=../../rm_bridge/model_modifier/changeset/snapshot_input.schema.json -- id: project/space/example title - long_name: example title - data_types: - Type: - - Unset - - Folder - - Functional - - Non-Functional - Release: - - Rel. 1 - requirement_types: - system_requirement: - long_name: System Requirement - attributes: - Capella ID: - type: String - Type: - type: Enum - data_type: Type - Submitted at: - type: Date - Release: - type: Enum - data_type: Release - multi_values: true - Test after migration: - type: String - software_requirement: - long_name: Software Requirement - attributes: - Capella ID: - type: String - Type: - type: Enum - data_type: Type - Submitted at: - type: Date - stakeholder_requirement: - long_name: Stakeholders Requirement - attributes: - Capella ID: - type: String - items: - - id: REQ-001 - long_name: Non-Functional Requirements - text:

Changed Test Description

- type: system_requirement - attributes: - Capella ID: RF-NFNC-00001 - Type: [Non-Functional] - Release: - - Rel. 1 - children: - - id: REQ-002 - long_name: Non-Function Requirement - text: ... - type: system_requirement - attributes: - Capella ID: R-NFNC-00002 - Type: [Non-Functional] - Submitted at: 2022-06-30 17:07:18.664000+02:00 - Test after migration: New - - id: REQ-003 - long_name: Functional Requirements - text:

Brand new

- type: software_requirement - attributes: - Type: [Folder] - children: - - id: REQ-004 - long_name: Function Requirement - type: software_requirement - attributes: - Capella ID: R-FNC-00001 - Type: [Unset] +# yaml-language-server: $schema=../../../capella_rm_bridge/changeset/snapshot_input.schema.json +metadata: + tool: RM Tool Version + revision: r1234 + connector: RM-Bridge-Polarion vX.Y.Z +modules: + - id: project/space/example title + long_name: example title + data_types: + Type: + - Unset + - Folder + - Functional + - Non-Functional + Release: + - Rel. 1 + requirement_types: + system_requirement: + long_name: System Requirement + attributes: + Capella ID: + type: String + Type: + type: Enum + Submitted at: + type: Date + Release: + type: Enum + multi_values: true + Test after migration: + type: String + software_requirement: + long_name: Software Requirement + attributes: + Capella ID: + type: String + Type: + type: Enum + Submitted at: + type: Date + stakeholder_requirement: + long_name: Stakeholders Requirement + attributes: + Capella ID: + type: String + items: + - id: REQ-001 + long_name: Non-Functional Requirements + text:

Changed Test Description

+ type: system_requirement + attributes: + Capella ID: RF-NFNC-00001 + Type: [Non-Functional] + Release: + - Rel. 1 + children: + - id: REQ-002 + long_name: Non-Function Requirement + text: ... + type: system_requirement + attributes: + Capella ID: R-NFNC-00002 + Type: [Non-Functional] + Submitted at: 2022-06-30 17:07:18.664000+02:00 + Test after migration: New + - id: REQ-003 + long_name: Functional Requirements + text:

Brand new

+ type: software_requirement + attributes: + Type: [Folder] + children: + - id: REQ-004 + long_name: Function Requirement + type: software_requirement + attributes: + Capella ID: R-FNC-00001 + Type: [Unset] diff --git a/tests/data/snapshots/snapshot2.yaml b/tests/data/snapshots/snapshot2.yaml index 4f84b09..a28d121 100644 --- a/tests/data/snapshots/snapshot2.yaml +++ b/tests/data/snapshots/snapshot2.yaml @@ -1,40 +1,43 @@ # SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-rm-bridge contributors # SPDX-License-Identifier: Apache-2.0 -# yaml-language-server: $schema=../../rm_bridge/model_modifier/changeset/snapshot_input.schema.json -- id: project/space/example title - long_name: example title - data_types: - Type: - - Unset - - Folder - - Non-Functional - requirement_types: - system_requirement: - long_name: System Requirement - attributes: - Capella ID: - type: String - Type: - type: Enum - data_type: Type - Submitted at: - type: Date - software_requirement: - long_name: Software Requirement - attributes: - Capella ID: - type: String - Type: - type: Enum - data_type: Type - Submitted at: - type: Date - items: - - id: REQ-001 - long_name: Non-Functional Requirements - text:

Changed Test Description

- type: system_requirement - attributes: - Capella ID: RF-NFNC-00001 - Type: [Non-Functional] +# yaml-language-server: $schema=../../../capella_rm_bridge/changeset/snapshot_input.schema.json +metadata: + tool: RM Tool Version + revision: r1234 + connector: RM-Bridge-Polarion vX.Y.Z +modules: + - id: project/space/example title + long_name: example title + data_types: + Type: + - Unset + - Folder + - Non-Functional + requirement_types: + system_requirement: + long_name: System Requirement + attributes: + Capella ID: + type: String + Type: + type: Enum + Submitted at: + type: Date + software_requirement: + long_name: Software Requirement + attributes: + Capella ID: + type: String + Type: + type: Enum + Submitted at: + type: Date + items: + - id: REQ-001 + long_name: Non-Functional Requirements + text:

Changed Test Description

+ type: system_requirement + attributes: + Capella ID: RF-NFNC-00001 + Type: [Non-Functional] diff --git a/tests/test_changeset.py b/tests/test_changeset.py index b8f4862..cf1639b 100644 --- a/tests/test_changeset.py +++ b/tests/test_changeset.py @@ -34,7 +34,7 @@ ) TEST_SNAPSHOT_PATH = TEST_DATA_PATH / "snapshots" -TEST_SNAPSHOT: list[actiontypes.TrackerSnapshot] = yaml.safe_load( +TEST_SNAPSHOT: actiontypes.Snapshot = yaml.safe_load( (TEST_SNAPSHOT_PATH / "snapshot.yaml").read_text(encoding="utf-8") ) TEST_SNAPSHOT_1 = yaml.safe_load( @@ -99,7 +99,9 @@ def test_init_on_missing_capella_UUID_raises_InvalidTrackerConfig( del tconfig["capella-uuid"] # type:ignore[misc] with pytest.raises(actiontypes.InvalidTrackerConfig): - self.tracker_change(clean_model, TEST_SNAPSHOT[0], tconfig) + self.tracker_change( + clean_model, TEST_SNAPSHOT["modules"][0], tconfig + ) def test_init_on_missing_module_raises_MissingRequirementsModule( self, clean_model: capellambse.MelodyModel @@ -114,12 +116,12 @@ def test_init_on_missing_module_raises_MissingRequirementsModule( del clean_model.la.requirement_modules[0] with pytest.raises(change.MissingRequirementsModule): - self.tracker_change(clean_model, TEST_SNAPSHOT[0]) + self.tracker_change(clean_model, TEST_SNAPSHOT["modules"][0]) def test_init_on_missing_module_id_raises_InvalidSnapshotModule( self, clean_model: capellambse.MelodyModel ) -> None: - snapshot = copy.deepcopy(TEST_SNAPSHOT[0]) + snapshot = copy.deepcopy(TEST_SNAPSHOT["modules"][0]) del snapshot["id"] # type: ignore[misc] with pytest.raises(actiontypes.InvalidSnapshotModule): @@ -129,7 +131,7 @@ def test_init_on_missing_module_id_raises_InvalidSnapshotModule( class TestCreateActions(ActionsTest): """UnitTests for all methods requesting creations.""" - tracker = TEST_SNAPSHOT[0] + tracker = TEST_SNAPSHOT["modules"][0] titem = tracker["items"][0] tracker_change_creations = TEST_MODULE_CHANGE[0]["extend"] @@ -272,7 +274,7 @@ def test_calculate_change_sets( ) -> None: """Test ``ChangeSet`` on clean model for first migration run.""" change_set, errors = calculate_change_set( - clean_model, TEST_CONFIG["modules"][0], TEST_SNAPSHOT[0] + clean_model, TEST_CONFIG["modules"][0], TEST_SNAPSHOT["modules"][0] ) assert not errors @@ -282,7 +284,7 @@ def test_calculate_change_sets( class TestModActions(ActionsTest): """Tests all methods that request modifications.""" - tracker = TEST_SNAPSHOT_1[0] + tracker = TEST_SNAPSHOT_1["modules"][0] titem = tracker["items"][0] ENUM_DATA_TYPE_MODS = TEST_MODULE_CHANGE_1[:2] @@ -295,7 +297,9 @@ def test_mod_data_type_definition_actions( ) -> None: r"""Test producing ``ModAction``\ s for EnumDataTypeDefinitions.""" snapshot = copy.deepcopy(self.tracker) - snapshot["requirement_types"] = TEST_SNAPSHOT[0]["requirement_types"] + snapshot["requirement_types"] = TEST_SNAPSHOT["modules"][0][ + "requirement_types" + ] snapshot["items"] = [] tchange = self.tracker_change(migration_model, snapshot) @@ -308,8 +312,8 @@ def test_mod_requirement_type_actions( ) -> None: r"""Test producing ``ModAction``\ s for RequirementTypes.""" snapshot = copy.deepcopy(self.tracker) - snapshot["data_types"] = TEST_SNAPSHOT[0]["data_types"] - snapshot["items"] = TEST_SNAPSHOT[0]["items"] + snapshot["data_types"] = TEST_SNAPSHOT["modules"][0]["data_types"] + snapshot["items"] = TEST_SNAPSHOT["modules"][0]["items"] tchange = self.tracker_change(migration_model, snapshot) @@ -352,7 +356,9 @@ def test_calculate_change_sets( ) -> None: """Test ChangeSet on clean model for first migration run.""" change_set, errors = calculate_change_set( - migration_model, TEST_CONFIG["modules"][0], TEST_SNAPSHOT_1[0] + migration_model, + TEST_CONFIG["modules"][0], + TEST_SNAPSHOT_1["modules"][0], ) assert not errors @@ -362,7 +368,7 @@ def test_calculate_change_sets( class TestDeleteActions(ActionsTest): """Test all methods that request deletions.""" - tracker = TEST_SNAPSHOT_2[0] + tracker = TEST_SNAPSHOT_2["modules"][0] titem = tracker["items"][0] REQ_TYPE_FOLDER_DEL = TEST_MODULE_CHANGE_2[0] @@ -402,7 +408,9 @@ def test_delete_data_type_definition_actions( ) -> None: """Test that EnumDataTypeDefinitions are deleted.""" snapshot = copy.deepcopy(self.tracker) - snapshot["requirement_types"] = TEST_SNAPSHOT_1[0]["requirement_types"] + snapshot["requirement_types"] = TEST_SNAPSHOT_1["modules"][0][ + "requirement_types" + ] snapshot["items"] = [] data_type_del = copy.deepcopy(self.REQ_TYPE_FOLDER_DEL) del data_type_del["delete"]["requirement_types"] @@ -419,7 +427,7 @@ def test_delete_requirement_type_actions( ) -> None: """Test that RequirementTypes are deleted.""" snapshot = copy.deepcopy(self.tracker) - snapshot["data_types"] = TEST_SNAPSHOT_1[0]["data_types"] + snapshot["data_types"] = TEST_SNAPSHOT_1["modules"][0]["data_types"] snapshot["items"] = [] req_type_del = copy.deepcopy(self.REQ_TYPE_FOLDER_DEL) del req_type_del["delete"]["data_type_definitions"] @@ -435,8 +443,10 @@ def test_delete_requirements_actions( ) -> None: """Test that RequirementsModActions are produced.""" snapshot = copy.deepcopy(self.tracker) - snapshot["data_types"] = TEST_SNAPSHOT_1[0]["data_types"] - snapshot["requirement_types"] = TEST_SNAPSHOT_1[0]["requirement_types"] + snapshot["data_types"] = TEST_SNAPSHOT_1["modules"][0]["data_types"] + snapshot["requirement_types"] = TEST_SNAPSHOT_1["modules"][0][ + "requirement_types" + ] requirement_del = self.resolve_ChangeSet(deletion_model, self.REQ_DEL) tchange = self.tracker_change(deletion_model, snapshot) @@ -457,7 +467,9 @@ def test_calculate_change_sets( ) change_set, errors = calculate_change_set( - deletion_model, TEST_CONFIG["modules"][0], TEST_SNAPSHOT_2[0] + deletion_model, + TEST_CONFIG["modules"][0], + TEST_SNAPSHOT_2["modules"][0], ) assert not errors @@ -485,7 +497,10 @@ def test_missing_module_UUID_logs_InvalidTrackerConfig_error( with caplog.at_level(logging.ERROR): calculate_change_set( - clean_model, config, TEST_SNAPSHOT[0], gather_logs=False + clean_model, + config, + TEST_SNAPSHOT["modules"][0], + gather_logs=False, ) assert caplog.messages[0] == f"{self.SKIP_MESSAGE}. {message}" @@ -505,7 +520,10 @@ def test_missing_module_logs_MissingRequirementsModule_error( with caplog.at_level(logging.ERROR): calculate_change_set( - clean_model, tconfig, TEST_SNAPSHOT[0], gather_logs=False + clean_model, + tconfig, + TEST_SNAPSHOT["modules"][0], + gather_logs=False, ) assert caplog.messages[0] == f"{self.SKIP_MESSAGE}. {message}" @@ -515,7 +533,7 @@ def test_missing_module_id_logs_InvalidSnapshotModule_error( clean_model: capellambse.MelodyModel, caplog: pytest.LogCaptureFixture, ) -> None: - snapshot = copy.deepcopy(TEST_SNAPSHOT[0]) + snapshot = copy.deepcopy(TEST_SNAPSHOT["modules"][0]) del snapshot["id"] # type: ignore[misc] tconfig = TEST_CONFIG["modules"][0] message = ( @@ -542,7 +560,7 @@ def test_init_errors_are_gathered( ) _, errors = calculate_change_set( - clean_model, config, TEST_SNAPSHOT[0], gather_logs=True + clean_model, config, TEST_SNAPSHOT["modules"][0], gather_logs=True ) assert errors[0].startswith(self.SKIP_MESSAGE) @@ -551,7 +569,7 @@ def test_init_errors_are_gathered( def test_snapshot_errors_from_ChangeSet_calculation_are_gathered( self, clean_model: capellambse.MelodyModel ) -> None: - snapshot = copy.deepcopy(TEST_SNAPSHOT[0]) + snapshot = copy.deepcopy(TEST_SNAPSHOT["modules"][0]) titem = snapshot["items"][0] first_child = titem["children"][0] titem["attributes"]["Test"] = 1 # type: ignore[index] From 08382d0d8764b0d3828fefe2ade1c3ba173275e2 Mon Sep 17 00:00:00 2001 From: ewuerger Date: Wed, 8 Feb 2023 11:44:34 +0100 Subject: [PATCH 2/2] fix: Update link to docs in `README` --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 8d45f41..37fc8c1 100644 --- a/README.rst +++ b/README.rst @@ -37,7 +37,7 @@ Documentation Read the `full documentation on Github pages`__. -__ https://dsd-dbs.github.io/capellambse-rm-bridge +__ https://dsd-dbs.github.io/capella-rm-bridge Installation ------------