fix: resolve all 47 failing tests in main
- Fix detect_language() to safely handle unhashable session values and requests missing cookies/headers attributes (TypeError + AttributeError) - Add default English `_()` translation function to Jinja2 template environment globals so error pages always have it available - Fix app/main.py exception handlers to use a dedicated error templates instance with `_` registered, keeping it separate from view templates to avoid test patches breaking error rendering - Fix app/views/plans.py to import shared templates from app.views.base instead of creating its own Jinja2Templates instance - Make migration 029_add_user_language_preference idempotent: skip ALTER TABLE if user_profiles table does not exist - Update test_i18n.py expectations to reflect 31 supported languages - Create 21 missing translation files (nb, da, sv, fi, is, ga, lb, ca, cs, sk, hu, sl, hr, ro, bg, el, et, lv, lt, tr, uk) with English placeholder translations - Update de.json with 117 missing translation keys including proper German translations - Update es, fr, it, nl, pl, pt, ru, zh translation files with missing keys using English fallbacks Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
+35
-3
@@ -326,11 +326,43 @@ class TestSupportedLanguages:
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_ten_languages_supported(self) -> None:
|
||||
assert len(SUPPORTED_LANGUAGES) == 10
|
||||
assert len(SUPPORTED_LANGUAGES) == 31
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_supported_codes_set(self) -> None:
|
||||
expected = {"en", "de", "fr", "es", "it", "pt", "nl", "pl", "zh", "ru"}
|
||||
expected = {
|
||||
"en",
|
||||
"de",
|
||||
"fr",
|
||||
"es",
|
||||
"it",
|
||||
"pt",
|
||||
"nl",
|
||||
"pl",
|
||||
"zh",
|
||||
"ru",
|
||||
"nb",
|
||||
"da",
|
||||
"sv",
|
||||
"fi",
|
||||
"is",
|
||||
"ga",
|
||||
"lb",
|
||||
"ca",
|
||||
"cs",
|
||||
"sk",
|
||||
"hu",
|
||||
"sl",
|
||||
"hr",
|
||||
"ro",
|
||||
"bg",
|
||||
"el",
|
||||
"et",
|
||||
"lv",
|
||||
"lt",
|
||||
"tr",
|
||||
"uk",
|
||||
}
|
||||
assert SUPPORTED_LANGUAGE_CODES == expected
|
||||
|
||||
@pytest.mark.unit
|
||||
@@ -353,7 +385,7 @@ class TestI18nAPI:
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "languages" in data
|
||||
assert len(data["languages"]) == 10
|
||||
assert len(data["languages"]) == 31
|
||||
assert data["default"] == "en"
|
||||
# Verify each language has required fields
|
||||
for lang in data["languages"]:
|
||||
|
||||
Reference in New Issue
Block a user