Skip to content

Commit

Permalink
Add unit tests for language formatting and listing:
Browse files Browse the repository at this point in the history
- Positive and negative tests for format_sublanguage_name
- Test to validate the output of list_all_languages
  • Loading branch information
OmarAI2003 authored and DeleMike committed Oct 18, 2024
1 parent 775fb24 commit 0b75b4e
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions tests/load/test_update_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,72 @@ def test_get_language_from_iso_negative():
assert str(excp.value) == "IXI is currently not a supported ISO language."


@pytest.mark.parametrize(
"lang, expected_output",
[
("nynorsk", "Norwegian/Nynorsk"),
("bokmål", "Norwegian/Bokmål"),
("english", "English"),
],
)
def test_format_sublanguage_name_positive(lang, expected_output):
assert utils.format_sublanguage_name(lang) == expected_output


def test_format_sublanguage_name_negative():
with pytest.raises(ValueError) as excp:
_ = utils.format_sublanguage_name("soccer")

assert str(excp.value) == "SOCCER is not a valid language or sub-language."


def test_list_all_languages():
expected_languages = [
"arabic",
"basque",
"bengali",
"czech",
"danish",
"english",
"esperanto",
"estonian",
"finnish",
"french",
"german",
"greek",
"hausa",
"hebrew",
"hindi",
"urdu",
"indonesian",
"italian",
"japanese",
"kurmanji",
"latin",
"malay",
"malayalam",
"mandarin",
"nynorsk",
"bokmål",
"nigerian",
"polish",
"portuguese",
"shahmukhi",
"gurmukhi",
"russian",
"slovak",
"spanish",
"swahili",
"swedish",
"tajik",
"tamil",
"ukrainian",
"yoruba",
]

assert utils.list_all_languages() == expected_languages


def test_get_ios_data_path():
assert (
utils.get_ios_data_path("suomi")
Expand Down

0 comments on commit 0b75b4e

Please sign in to comment.