diff --git a/qc_baselib/models/config.py b/qc_baselib/models/config.py
index ab2244f..0ef4397 100644
--- a/qc_baselib/models/config.py
+++ b/qc_baselib/models/config.py
@@ -26,7 +26,7 @@ class ReportModuleType(BaseXmlModel):
application: str = attr(name="application")
-class CheckerBundleType(BaseXmlModel):
+class CheckerBundleType(BaseXmlModel, search_mode="unordered"):
params: List[ParamType] = element(tag="Param", default=[])
checkers: List[CheckerType] = element(tag="Checker", default=[])
application: str = attr(name="application")
@@ -40,7 +40,7 @@ def check_at_least_one_element(self) -> Any:
return self
-class Config(BaseXmlModel, tag="Config"):
+class Config(BaseXmlModel, tag="Config", search_mode="unordered"):
params: List[ParamType] = element(tag="Param", default=[])
reports: List[ReportModuleType] = element(tag="ReportModule", default=[])
checker_bundles: List[CheckerBundleType] = element(tag="CheckerBundle", default=[])
diff --git a/qc_baselib/models/result.py b/qc_baselib/models/result.py
index ff219ae..eccbf75 100644
--- a/qc_baselib/models/result.py
+++ b/qc_baselib/models/result.py
@@ -33,7 +33,7 @@ class FileLocationType(BaseXmlModel):
row: int = attr(name="row")
-class LocationType(BaseXmlModel):
+class LocationType(BaseXmlModel, search_mode="unordered"):
file_location: List[FileLocationType] = element(tag="FileLocation", default=[])
xml_location: List[XMLLocationType] = element(tag="XMLLocation", default=[])
inertial_location: List[InertialLocationType] = element(
@@ -44,7 +44,9 @@ class LocationType(BaseXmlModel):
@model_validator(mode="after")
def check_at_least_one_element(self) -> Any:
if (
- len(self.file_location) + len(self.xml_location) + len(self.inertial_location)
+ len(self.file_location)
+ + len(self.xml_location)
+ + len(self.inertial_location)
< 1
):
raise ValueError(
@@ -192,7 +194,7 @@ class StatusType(str, enum.Enum):
SKIPPED = "skipped"
-class CheckerType(BaseXmlModel, validate_assignment=True, search_mode="ordered"):
+class CheckerType(BaseXmlModel, validate_assignment=True, search_mode="unordered"):
addressed_rule: List[RuleType] = element(tag="AddressedRule", default=[])
issues: List[IssueType] = element(tag="Issue", default=[])
metadata: List[MetadataType] = element(tag="Metadata", default=[])
@@ -225,7 +227,7 @@ def check_skipped_status_containing_issues(self) -> Any:
return self
-class CheckerBundleType(BaseXmlModel):
+class CheckerBundleType(BaseXmlModel, search_mode="unordered"):
params: List[ParamType] = element(tag="Param", default=[])
checkers: List[CheckerType] = element(tag="Checker", default=[])
build_date: str = attr(name="build_date")
diff --git a/tests/data/ordered_config.xml b/tests/data/ordered_config.xml
new file mode 100644
index 0000000..e25be6a
--- /dev/null
+++ b/tests/data/ordered_config.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/data/unordered_config.xml b/tests/data/unordered_config.xml
new file mode 100644
index 0000000..74c932d
--- /dev/null
+++ b/tests/data/unordered_config.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/test_configuration.py b/tests/test_configuration.py
index 306ce10..33fa3a8 100644
--- a/tests/test_configuration.py
+++ b/tests/test_configuration.py
@@ -8,7 +8,7 @@
from qc_baselib.models import config, result
from qc_baselib import Configuration
-
+TEST_DATA_BASE_PATH = "tests/data"
DEMO_CONFIG_PATH = "tests/data/demo_checker_bundle_config.xml"
EXAMPLE_OUTPUT_CONFIG_PATH = "tests/data/config_test_output.xml"
TEST_CONFIG_OUTPUT_PATH = "tests/config_test_output.xml"
@@ -172,3 +172,27 @@ def test_config_write() -> None:
assert output_xml_text == example_xml_text
os.remove(TEST_CONFIG_OUTPUT_PATH)
+
+
+def test_config_file_parse_order_independence() -> None:
+ config_unordered = Configuration()
+ config_unordered.load_from_file(
+ os.path.join(TEST_DATA_BASE_PATH, "unordered_config.xml")
+ )
+
+ config_ordered = Configuration()
+ config_ordered.load_from_file(
+ os.path.join(TEST_DATA_BASE_PATH, "ordered_config.xml")
+ )
+
+ assert len(config_ordered._configuration.reports) == len(
+ config_unordered._configuration.reports
+ )
+
+ assert len(config_ordered._configuration.checker_bundles) == len(
+ config_unordered._configuration.checker_bundles
+ )
+
+ assert len(config_ordered._configuration.params) == len(
+ config_unordered._configuration.params
+ )