From 4c36e5c39d5d15f7b552821883e5e45195f4fe8d Mon Sep 17 00:00:00 2001 From: Rubel Date: Fri, 26 Apr 2024 16:03:27 +0200 Subject: [PATCH] Checkpoints for existing default attrib. --- pynxtools/dataconverter/helpers.py | 3 --- tests/dataconverter/test_helpers.py | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pynxtools/dataconverter/helpers.py b/pynxtools/dataconverter/helpers.py index c75ebf73c..b676a07dc 100644 --- a/pynxtools/dataconverter/helpers.py +++ b/pynxtools/dataconverter/helpers.py @@ -867,9 +867,6 @@ def set_default_attr_in_group(template): for template_concept, val in template.items(): # skip the last part which is field groups_list = template_concept.split("/") - # Cancel out the attribuutes - if groups_list[-1].startswith("@"): - continue # Cancel out the fields and end groups without fields groups_list = groups_list[0:-1] if not groups_list: diff --git a/tests/dataconverter/test_helpers.py b/tests/dataconverter/test_helpers.py index 3dabdb7b5..a03c0be28 100644 --- a/tests/dataconverter/test_helpers.py +++ b/tests/dataconverter/test_helpers.py @@ -471,6 +471,9 @@ def test_path_in_data_dict(nxdl_path, expected, template): "/ENTRY[entry1]/NXODD_name[nxodd_name_2]/float_value": 8.0, "/ENTRY[entry1]/NXODD_name[nxodd_name_2]/DATA[data1]/data1": [3, 5, 6], "/ENTRY[entry1]/NXODD_name[nxodd_name_2]/DATA[data2]/data2": [3, 5, 6], + "/ENTRY[entry2]/@default": "nxodd_name_2", + "/ENTRY[entry2]/NXODD_name[nxodd_name]/float_value": 2.0, + "/ENTRY[entry2]/NXODD_name[nxodd_name_2]/float_value": 8.0, } ], ) @@ -511,6 +514,9 @@ def test_set_default_attr_in_group(temp_dict): "Group can not have a default attribute refering any field," " unless it is not supplied by reader." ) + assert ( + template["/ENTRY[entry2]/@default"] == "nxodd_name_2" + ), "Default attribute supplied by reader can not be overwritten." def test_atom_type_extractor_and_hill_conversion():