Skip to content

Commit

Permalink
expand tests to more various scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
KeynesYouDigIt committed Jun 1, 2019
1 parent 9145b5d commit ae3620c
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions pyxform/tests_v1/test_language_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_label_with_unknown_subtag_should_warn(self):
'do not contain valid machine-readable codes: English (schm). Learn more' in warnings[0])
os.unlink(tmp.name)

def test_no_default_language_should_warn_with_unlabeled_media_tags(self):
def test_missing_translation_no_default_lang_media_has_no_language(self):
# form should test media tag w NO default language set.
survey = self.md_to_pyxform_survey("""
| survey | | | | |
Expand All @@ -88,11 +88,11 @@ def test_no_default_language_should_warn_with_unlabeled_media_tags(self):
self.assertTrue(len(warnings) == 2)
os.unlink(tmp.name)

def test_language_lacking_translation_should_warn(self):
def test_missing_translation_media(self):
survey = self.md_to_pyxform_survey("""
| survey | | | | |
| | type | name | label::English (en) | media::image::French (fr)|
| | integer | nums | How many nums? | opt1.jpg |
| survey | | | | | |
| | type | name | label::English (en) | label::French (fr) | media::image::French (fr)|
| | integer | nums | How many nums? | Combien noms? | opt1.jpg |
""")

warnings = []
Expand All @@ -102,7 +102,24 @@ def test_language_lacking_translation_should_warn(self):

# In this survey, when 'French (fr)' s selected the label of this question will be '-'.
# Also, when 'English (en)` is selected, the medial will be '-'
self.assertTrue(len(warnings) == 2)
self.assertTrue(len(warnings) == 1)
os.unlink(tmp.name)

def test_missing_translation_hint(self):
survey = self.md_to_pyxform_survey("""
| survey | | | | | |
| | type | name | label::English (en) | label::French (fr) | hint::French (fr) |
| | integer | nums | How many nums? | Combien noms? | noms est nombres |
""")

warnings = []
tmp = tempfile.NamedTemporaryFile(suffix='.xml', delete=False)
tmp.close()
survey.print_xform_to_file(tmp.name, warnings=warnings)

# In this survey, when 'French (fr)' s selected the label of this question will be '-'.
# Also, when 'English (en)` is selected, the medial will be '-'
self.assertTrue(len(warnings) == 1)
os.unlink(tmp.name)

def test_default_language_only_should_not_warn(self):
Expand Down

0 comments on commit ae3620c

Please sign in to comment.