Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass through itemset ref case #644

Merged
merged 2 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 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