mirror of
https://github.com/apache/superset.git
synced 2026-07-25 16:12:39 +00:00
fix(i18n): accept script-subtag locales, annotate test helper return type
The language-code regex only allowed a 2-letter region subtag, so locales Superset actually ships with a script subtag (e.g. sr_Latn) were rejected by /language_pack/<lang>/<version>/script.js with a 400 and silently fell back to English. Widen the shared LANGUAGE_CODE_RE to accept both region and script subtags, and add a regression test. Also gives the test helper an explicit dict[str, Any] return type so the inferred `context` locals in test_bootstrap_auth.py are annotated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -78,6 +78,21 @@ def test_script_rejects_malformed_lang_and_version(client: Any) -> None:
|
||||
assert client.get("/language_pack/fr/not-a-hash!/script.js").status_code == 400
|
||||
|
||||
|
||||
def test_script_accepts_script_subtag_locale(client: Any) -> None:
|
||||
"""Script-subtag locales Superset ships (e.g. sr_Latn) must not be
|
||||
rejected by the language-code validation."""
|
||||
with (
|
||||
patch(
|
||||
"superset.views.core.get_language_pack_version",
|
||||
return_value=FAKE_VERSION,
|
||||
),
|
||||
patch("superset.views.core.get_language_pack", return_value=FAKE_PACK),
|
||||
):
|
||||
response = client.get(f"/language_pack/sr_Latn/{FAKE_VERSION}/script.js")
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_script_serves_only_the_requested_locale(client: Any) -> None:
|
||||
"""The endpoint resolves exactly one pack: the locale in the URL."""
|
||||
with (
|
||||
|
||||
Reference in New Issue
Block a user