diff --git a/pyxform/validators/pyxform/parameters_generic.py b/pyxform/validators/pyxform/parameters_generic.py index a1084787..c855e422 100644 --- a/pyxform/validators/pyxform/parameters_generic.py +++ b/pyxform/validators/pyxform/parameters_generic.py @@ -4,6 +4,9 @@ PARAMETERS_TYPE = Dict[str, Any] +# Label and value are used to match against user-specified files so case should be preserved. +CASE_SENSITIVE_VALUES = ["label", "value"] + def parse(raw_parameters: str) -> PARAMETERS_TYPE: parts = raw_parameters.split(";") @@ -21,7 +24,7 @@ def parse(raw_parameters: str) -> PARAMETERS_TYPE: ) k, v = param.split("=")[:2] key = k.lower().strip() - params[key] = v.lower().strip() + params[key] = v.strip() if key in CASE_SENSITIVE_VALUES else v.lower().strip() return params diff --git a/tests/test_external_instances_for_selects.py b/tests/test_external_instances_for_selects.py index 31f7e5cd..fb700978 100644 --- a/tests/test_external_instances_for_selects.py +++ b/tests/test_external_instances_for_selects.py @@ -242,6 +242,24 @@ def test_param_value_and_label_validation(self): error__contains=[msg], ) + def test_param_value_case_preserved(self): + """Should find that parameters value/label override the default itemset name/label with case preserved.""" + md = """ + | survey | | | | | + | | type | name | label | parameters | + | | select_one_from_file cities{ext} | city | City | value=VAL, label=lBl | + """ + for ext, xp_city, xp_subs in self.xp_test_args: + with self.subTest(msg=ext): + self.assertPyxformXform( + name="test", + md=md.format(ext=ext), + xml__xpath_match=[ + xp_city.model_external_instance_and_bind(), + xp_city.body_itemset_nodeset_and_refs(value="VAL", label="lBl"), + ], + ) + class TestSelectOneExternal(PyxformTestCase): """