Skip to content

Commit 482ea8f

Browse files
Fix fallbacks test
1 parent dd5513e commit 482ea8f

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

app/backend/src/tests/test_i18n_locales.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from couchers.i18n.locales import (
44
DEFAULT_LOCALE,
55
get_babel_locale,
6+
get_locale_chain,
67
get_main_i18next,
78
get_supported_locales,
89
to_supported_locale,
@@ -51,17 +52,11 @@ def test_all_supported_locales_have_babel_locales():
5152
assert get_babel_locale(locale), f"Locale {locale} does not have a valid Babel locale"
5253

5354

54-
def test_fallback_chain():
55+
def test_get_locale_chain():
5556
"""Test that fallbacks are correctly set up"""
56-
i18next = get_main_i18next()
57-
58-
# Example: fr-CA should fallback to fr, which should fallback to en
59-
fr_CA = i18next.translations_by_locale["fr-CA"]
60-
fr = i18next.translations_by_locale["fr"]
61-
en = i18next.translations_by_locale["en"]
62-
63-
assert fr_CA.fallbacks == [fr, en]
64-
assert fr.fallbacks == [en]
65-
assert en.fallbacks == []
66-
67-
assert i18next.default_translation == en
57+
assert get_locale_chain("en") == ["en"]
58+
assert get_locale_chain("pl") == ["pl", "en"]
59+
assert get_locale_chain("xx") == ["xx", "en"]
60+
assert get_locale_chain("fr-CA") == ["fr-CA", "fr", "en"]
61+
assert get_locale_chain("pt") == ["pt", "pt-BR", "en"]
62+
assert get_locale_chain("pt-BR") == ["pt-BR", "pt", "en"]

0 commit comments

Comments
 (0)