Skip to content

Commit

Permalink
Make tests have more realistic search() usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lognaturel committed Jan 26, 2024
1 parent 847d9c8 commit cd9ba6c
Showing 1 changed file with 11 additions and 38 deletions.
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"""
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

0 comments on commit cd9ba6c

Please sign in to comment.