Skip to content

Commit

Permalink
Pass through itemset ref case
Browse files Browse the repository at this point in the history
  • Loading branch information
lognaturel committed May 10, 2023
1 parent 62c26ce commit 22d885c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyxform/validators/pyxform/parameters_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

PARAMETERS_TYPE = Dict[str, Any]

CASE_SENSITIVE_VALUES = ["label", "value"]


def parse(raw_parameters: str) -> PARAMETERS_TYPE:
parts = raw_parameters.split(";")
Expand All @@ -21,7 +23,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

Expand Down
18 changes: 18 additions & 0 deletions tests/test_external_instances_for_selects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 22d885c

Please sign in to comment.