diff options
| author | David <david.anthony.lei@gmail.com> | 2018-09-03 18:43:55 +1000 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2018-09-03 10:43:55 +0200 |
| commit | 5db8d617c0a5b16fabe16d1d52b2f9db519d8bb6 (patch) | |
| tree | f19bc95d9915224ca7522a3d4daeff0f2ee4856b /tests/check_framework | |
| parent | ee52044a278885bd9455dd59b1e16c5d5e2d68ce (diff) | |
Fixed #29713 -- Added check that LANGUAGE_CODE uses standard language id format.
Diffstat (limited to 'tests/check_framework')
| -rw-r--r-- | tests/check_framework/test_translation.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/check_framework/test_translation.py b/tests/check_framework/test_translation.py new file mode 100644 index 0000000000..9ff698c29f --- /dev/null +++ b/tests/check_framework/test_translation.py @@ -0,0 +1,39 @@ +from django.core.checks.translation import check_setting_language_code +from django.test import SimpleTestCase, override_settings + + +class TranslationCheckTests(SimpleTestCase): + + @override_settings(LANGUAGE_CODE="eu") + def test_valid_language_code_format_ll_only(self): + result = check_setting_language_code(None) + self.assertEqual(len(result), 0) + + @override_settings(LANGUAGE_CODE="eü") + def test_invalid_language_code_format_ll_only(self): + result = check_setting_language_code(None) + self.assertEqual(len(result), 1) + error = result[0] + self.assertEqual(error.id, 'translation.E001') + self.assertEqual(error.msg, ( + "LANGUAGE_CODE in settings.py is eü. It should be in the form ll or ll-cc where ll is the language and cc " + "is the country. Examples include: it, de-at, es, pt-br. The full set of language codes specifications is " + "outlined by https://en.wikipedia.org/wiki/IETF_language_tag#Syntax_of_language_tags" + )) + + @override_settings(LANGUAGE_CODE="en-US") + def test_valid_language_code_format_ll_cc(self): + result = check_setting_language_code(None) + self.assertEqual(len(result), 0) + + @override_settings(LANGUAGE_CODE="en_US") + def test_invalid_language_code_format_ll_cc(self): + result = check_setting_language_code(None) + self.assertEqual(len(result), 1) + error = result[0] + self.assertEqual(error.id, 'translation.E001') + self.assertEqual(error.msg, ( + "LANGUAGE_CODE in settings.py is en_US. It should be in the form ll or ll-cc where ll is the language and " + "cc is the country. Examples include: it, de-at, es, pt-br. The full set of language codes specifications " + "is outlined by https://en.wikipedia.org/wiki/IETF_language_tag#Syntax_of_language_tags" + )) |
