From 3cdef2d34712737127023f8d32fe6d97bc0881ae Mon Sep 17 00:00:00 2001 From: Torsten Knodt Date: Thu, 13 Feb 2025 21:34:03 +0100 Subject: [PATCH] 175: Initial commit to create respective SpecObjectAttribute's to confirm that integration tests fail --- reqif/models/reqif_spec_object.py | 4 +- .../01_create_reqif_objects/script.py | 46 ++++++++++++++++--- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/reqif/models/reqif_spec_object.py b/reqif/models/reqif_spec_object.py index e7bf204..c2add3c 100644 --- a/reqif/models/reqif_spec_object.py +++ b/reqif/models/reqif_spec_object.py @@ -10,13 +10,13 @@ def __init__( # pylint: disable=too-many-arguments self, attribute_type: SpecObjectAttributeType, definition_ref: str, - value: Union[str, List[str]], + value: Union[bool, float, int, str, List[str]], value_stripped_xhtml: Optional[str] = None, xml_node: Optional[Any] = None, ): self.attribute_type: SpecObjectAttributeType = attribute_type self.definition_ref: str = definition_ref - self.value: Union[str, List[str]] = value + self.value: Union[bool, float, int, str, List[str]] = value # Only for XHTML attributes: A value stripped of the # namespace. becomes
... self.value_stripped_xhtml: Optional[str] = value_stripped_xhtml diff --git a/tests/integration/examples/01_create_reqif_objects/script.py b/tests/integration/examples/01_create_reqif_objects/script.py index 2bfd242..2d3bbf7 100644 --- a/tests/integration/examples/01_create_reqif_objects/script.py +++ b/tests/integration/examples/01_create_reqif_objects/script.py @@ -32,7 +32,7 @@ class ExampleIdentifiers: # For example, 550e8400-e29b-41d4-a716-446655440000 or similar. # For this example, we keep it as strings. STRING_DATATYPE_ID = create_uuid() - SPEC_ATTRIBUTE_ID = create_uuid() + SPEC_ATTRIBUTE_IDs = list(map(create_uuid, range(9))) SPEC_OBJECT_TYPE_ID = create_uuid() SPEC_OBJECT_ID = create_uuid() SPEC_HIERARCHY_ID = create_uuid() @@ -63,15 +63,47 @@ class ExampleIdentifiers: attribute_definitions=[requirement_text_attribute], ) -spec_object_attribute = SpecObjectAttribute( - attribute_type=SpecObjectAttributeType.STRING, - definition_ref=ExampleIdentifiers.SPEC_ATTRIBUTE_ID, - value="System ABC shall do XYQ.", -) +spec_object_attributes = [ + SpecObjectAttribute( + attribute_type=SpecObjectAttributeType.STRING, + definition_ref=ExampleIdentifiers.SPEC_ATTRIBUTE_IDs[0], + value="System ABC shall do XYQ.", + ), + SpecObjectAttribute( + attribute_type=SpecObjectAttributeType.INTEGER, + definition_ref=ExampleIdentifiers.SPEC_ATTRIBUTE_IDs[1], + value="1", + ), + SpecObjectAttribute( + attribute_type=SpecObjectAttributeType.INTEGER, + definition_ref=ExampleIdentifiers.SPEC_ATTRIBUTE_IDs[2], + value=1, + ), + SpecObjectAttribute( + attribute_type=SpecObjectAttributeType.REAL, + definition_ref=ExampleIdentifiers.SPEC_ATTRIBUTE_IDs[3], + value="1.0", + ), + SpecObjectAttribute( + attribute_type=SpecObjectAttributeType.REAL, + definition_ref=ExampleIdentifiers.SPEC_ATTRIBUTE_IDs[4], + value=1.0, + ), + SpecObjectAttribute( + attribute_type=SpecObjectAttributeType.BOOLEAN, + definition_ref=ExampleIdentifiers.SPEC_ATTRIBUTE_IDs[5], + value=False, + ), + SpecObjectAttribute( + attribute_type=SpecObjectAttributeType.BOOLEAN, + definition_ref=ExampleIdentifiers.SPEC_ATTRIBUTE_IDs[6], + value=True, + ), +] spec_object = ReqIFSpecObject( identifier=ExampleIdentifiers.SPEC_OBJECT_ID, - attributes=[spec_object_attribute], + attributes=spec_object_attributes, spec_object_type=spec_object_type.identifier, last_change=date_now, )