Skip to content

Commit

Permalink
enhance test
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri committed Jul 20, 2023
1 parent c65dc99 commit d89f65e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Binary file not shown.
Binary file not shown.
29 changes: 21 additions & 8 deletions onadata/libs/tests/utils/test_export_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2050,10 +2050,10 @@ def _test_sav_file(section):
section_name = section["name"].replace("/", "_")
_test_sav_file(section_name)

def test_export_zipped_zap_choices_label_language_missing(self):
"""Missing choice language label defaults to label for default language"""
def test_export_zipped_zap_missing_lang_label(self):
"""Blank language label defaults to label for default language"""
survey = create_survey_from_xls(
_logger_fixture_path("childrens_survey_sw_missing_choice_lang.xlsx"),
_logger_fixture_path("childrens_survey_sw_missing_lang_label.xlsx"),
default_name="childrens_survey_sw",
)
# default_language is set to swahili
Expand All @@ -2075,15 +2075,28 @@ def test_export_zipped_zap_choices_label_language_missing(self):

# check that each file exists
self.assertTrue(os.path.exists(os.path.join(temp_dir, f"{survey.name}.sav")))
checks = 0

for section in export_builder.sections:
if section == "children":
section_name = section["name"]

if section_name == "childrens_survey_sw":
result = filter(
lambda label: label == "fav_colors/Nyekundu",
section["children"]["elements"],
lambda question: question["label"] == "1. Jina lako ni?",
section["elements"],
)
self.assertEqual(len(result), 1)
break
self.assertEqual(len(list(result)), 1)
checks += 1

if section_name == "children":
result = filter(
lambda choice: choice["label"] == "fav_colors/Nyekundu",
section["elements"],
)
self.assertEqual(len(list(result)), 1)
checks += 1

self.assertEqual(checks, 2)

# pylint: disable=invalid-name
def test_generate_field_title_truncated_titles(self):
Expand Down

0 comments on commit d89f65e

Please sign in to comment.