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

Make tests have more realistic search() usage #691

Closed
wants to merge 1 commit into from
Closed
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
49 changes: 11 additions & 38 deletions tests/test_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1556,48 +1556,22 @@ def test_choice_name_containing_dash_output_itext(self):
class TestTranslationsSearchAppearance(PyxformTestCase):
"""Translations behaviour with the search() appearance."""

def test_shared_choice_list(self):
"""Should include translation for search() items, sharing the choice list"""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't understand the purpose of this test! I don't think there's any realistic case in which the search() configuration list would be used elsewhere. But also that's not what the test seemed to do (and maybe that's why the PR was marked as draft)

def test_translations_for_search(self):
"""Should include translation for search() items"""
md = """
| survey | | | | | |
| | type | name | label::en | label::fr | appearance |
| | select_one c1 | q1 | Question 1 | Chose 1 | search('my_file') |
| | select_one c2 | q2 | Question 2 | Chose 2 | |
| choices | | | | |
| | list_name | name | label::en | label::fr |
| | c1 | na | la-e | la-f |
| | c1 | nb | lb-e | lb-f |
| | c2 | na | la-e | la-f |
"""
self.assertPyxformXform(
md=md,
run_odk_validate=True,
xml__xpath_match=[
"/h:html/h:body/x:select1/x:item[./x:value/text()='na']",
xpc.model_itext_choice_text_label_by_pos("en", "c1", ("la-e", "lb-e")),
xpc.model_itext_choice_text_label_by_pos("fr", "c1", ("la-f", "lb-f")),
xpc.model_itext_choice_text_label_by_pos("en", "c2", ("la-e",)),
xpc.model_itext_choice_text_label_by_pos("fr", "c2", ("la-f",)),
],
)

def test_single_question_single_choice(self):
"""Should include translation for search() items, edge case of single elements"""
md = """
| survey | | | | | |
| | type | name | label::en | label::fr | appearance |
| | select_one c1 | q1 | Question 1 | Chose 1 | search('my_file') |
| choices | | | | |
| | list_name | name | label::en | label::fr |
| | c1 | na | la-e | la-f |
| | list_name | name | label::en | label::fr | |
| | c1 | id | label_en | label_fr | |
"""
self.assertPyxformXform(
md=md,
run_odk_validate=True,
xml__xpath_match=[
"/h:html/h:body/x:select1/x:item[./x:value/text()='na']",
xpc.model_itext_choice_text_label_by_pos("en", "c1", ("la-e",)),
xpc.model_itext_choice_text_label_by_pos("fr", "c1", ("la-f",)),
"/h:html/h:body/x:select1/x:item[./x:value/text()='id']",
xpc.model_itext_choice_text_label_by_pos("en", "c1", ("label_en",)),
xpc.model_itext_choice_text_label_by_pos("fr", "c1", ("label_fr",)),
],
)

Expand All @@ -1609,15 +1583,14 @@ def test_name_clashes(self):
| | select_one c1-0 | c1-0 | Question 1 | Chose 1 | search('my_file') |
| choices | | | | |
| | list_name | name | label::en | label::fr |
| | c1-0 | na | la-e | la-f |
| | c1-0 | id | label_en | label_fr |
"""
self.assertPyxformXform(
md=md,
run_odk_validate=True,
xml__xpath_match=[
"/h:html/h:body/x:select1/x:item[./x:value/text()='na']",
xpc.model_itext_choice_text_label_by_pos("en", "c1-0", ("la-e",)),
xpc.model_itext_choice_text_label_by_pos("fr", "c1-0", ("la-f",)),
"/h:html/h:body/x:select1/x:item[./x:value/text()='id']",
xpc.model_itext_choice_text_label_by_pos("en", "c1-0", ("label_en",)),
xpc.model_itext_choice_text_label_by_pos("fr", "c1-0", ("label_fr",)),
],
)

Expand Down
Loading