[API] Issue #205: Django i18n foundation validation hardening #217
@@ -2,6 +2,7 @@ import json
|
||||
import tempfile
|
||||
from datetime import timedelta
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.management import call_command
|
||||
@@ -1218,6 +1219,23 @@ class I18nResolverTests(TestCase):
|
||||
def test_missing_backend_key_returns_key_deterministically(self):
|
||||
self.assertEqual(resolve_error_message(key="missing_key", locale="da"), "missing_key")
|
||||
|
||||
def test_missing_backend_key_is_logged_with_context(self):
|
||||
with self.assertLogs("lobby.i18n", level="WARNING") as logs:
|
||||
result = resolve_error_message(key="missing_key", locale="da")
|
||||
|
||||
self.assertEqual(result, "missing_key")
|
||||
self.assertTrue(any("i18n key missing in shared catalog" in entry for entry in logs.output))
|
||||
|
||||
def test_missing_locale_translation_falls_back_to_default_locale(self):
|
||||
with patch(
|
||||
"lobby.i18n.lobby_i18n_error_messages",
|
||||
return_value={"session_code_required": {"en": "Session code is required"}},
|
||||
):
|
||||
self.assertEqual(
|
||||
resolve_error_message(key="session_code_required", locale="da"),
|
||||
"Session code is required",
|
||||
)
|
||||
|
||||
def test_shared_catalog_uses_en_default_and_da_en_matrix(self):
|
||||
default_locale, supported_locales = i18n_locale_config()
|
||||
catalog = lobby_i18n_catalog()
|
||||
|
||||
Reference in New Issue
Block a user