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

678: itextId node not added to instance items for choice list names with dashes in multilingual forms #680

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pyxform/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def _generate_static_instances(self, list_name, choice_list) -> InstanceInfo:
for items in self._translations.values()
for k, v in items.items()
if v.get(constants.TYPE, "") == constants.CHOICE
and k.split("-")[0] == list_name
and "-".join(k.split("-")[:-1]) == list_name
)
if 0 < len(choices):
multi_language = True
Expand Down
34 changes: 33 additions & 1 deletion tests/test_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ def test_specify_other__no_translations(self):
)

def test_specify_other__choice_filter(self):
"""Should raise an error since these featuers are unsupported together."""
"""Should raise an error since these features are unsupported together."""
md = """
| survey | | | |
| | type | name | label | choice_filter |
Expand All @@ -1753,3 +1753,35 @@ def test_specify_other__choice_filter(self):
errored=True,
error__contains=["[row : 3] Choice filter not supported with or_other."],
)

def test_choice_name_containing_dash_output_itext(self):
"""Should output itext when list_name contains a dash (itextId separator)."""
md = """
| survey | | | |
| | type | name | label:en | label:fr |
| | select_one with_us | q0 | Q1 EN | Q1 FR |
| | select_one with-dash | q1 | Q2 EN | Q2 FR |
| choices | | | |
| | list name | name | label:en | label:fr |
| | with_us | na | l1a-en | l1a-fr |
| | with_us | nb | l1b-en | l1b-fr |
| | with-dash | na | l2a-en | l2a-fr |
| | with-dash | nb | l2b-en | l2b-fr |
"""
self.assertPyxformXform(
md=md,
xml__xpath_match=[
xpc.model_itext_choice_text_label_by_pos(
"en", "with_us", ("l1a-en", "l1b-en")
),
xpc.model_itext_choice_text_label_by_pos(
"en", "with-dash", ("l2a-en", "l2b-en")
),
xpc.model_itext_choice_text_label_by_pos(
"fr", "with_us", ("l1a-fr", "l1b-fr")
),
xpc.model_itext_choice_text_label_by_pos(
"fr", "with-dash", ("l2a-fr", "l2b-fr")
),
],
)
Loading