Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions reqif/parsers/attribute_definition_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ def parse_attribute_definitions(

xml_default_value = attribute_definition.find("DEFAULT-VALUE")
if xml_default_value is not None:
xml_attribute_value = xml_default_value.find(
"ATTRIBUTE-VALUE-INTEGER"
)
xml_attribute_value = xml_default_value.find("ATTRIBUTE-VALUE-REAL")
assert xml_attribute_value is not None
default_value = xml_attribute_value.attrib["THE-VALUE"]

Expand Down
1 change: 1 addition & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def lint_mypy(context):
--disable-error-code=type-arg
--disable-error-code=union-attr
--strict
--no-site-packages
--python-version=3.9
""",
)
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/reqif/parsers/test_spec_type_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,33 @@ def test_06_string_attribute_default_value() -> None:
== "TEST_STRING_ATTRIBUTE_LONG_NAME"
)
assert reqif_spec_object_type.attribute_definitions[0].default_value == "TBD"


def test_07_real_attribute_definition_with_default_value() -> None:
spec_type_string = """
<SPEC-OBJECT-TYPE IDENTIFIER="TEST_SPEC_OBJECT_TYPE_ID" LAST-CHANGE="2021-02-08T16:37:07.454+01:00" LONG-NAME="TEST_SPEC_OBJECT_TYPE_LONG_NAME">
<SPEC-ATTRIBUTES>
<ATTRIBUTE-DEFINITION-REAL IDENTIFIER="TEST_REAL_ATTRIBUTE_ID" LONG-NAME="TEST_REAL_ATTRIBUTE_LONG_NAME" IS-EDITABLE="false">
<DEFAULT-VALUE>
<ATTRIBUTE-VALUE-REAL THE-VALUE="3.14"/>
</DEFAULT-VALUE>
<TYPE>
<DATATYPE-DEFINITION-REAL-REF>TEST_REAL_TYPE</DATATYPE-DEFINITION-REAL-REF>
</TYPE>
</ATTRIBUTE-DEFINITION-REAL>
</SPEC-ATTRIBUTES>
</SPEC-OBJECT-TYPE>
""" # noqa: E501
spec_type_xml = etree.fromstring(spec_type_string)

reqif_spec_object_type = SpecObjectTypeParser.parse(spec_type_xml)
assert isinstance(reqif_spec_object_type, ReqIFSpecObjectType)
assert reqif_spec_object_type.identifier == "TEST_SPEC_OBJECT_TYPE_ID"
assert reqif_spec_object_type.long_name == "TEST_SPEC_OBJECT_TYPE_LONG_NAME"
attribute_map = reqif_spec_object_type.attribute_map
assert len(attribute_map) == 1
assert (
attribute_map.get("TEST_REAL_ATTRIBUTE_ID").long_name
== "TEST_REAL_ATTRIBUTE_LONG_NAME"
)
assert reqif_spec_object_type.attribute_definitions[0].default_value == "3.14"
Loading