コード例 #1
0
 def test_mce_attrs_language_priority(self):
     widget = TinyMCE(mce_attrs={"language": "ru"})
     orig_config = tinymce.settings.DEFAULT_CONFIG
     with patch.dict(tinymce.settings.DEFAULT_CONFIG, {
             **orig_config, "language": "es_ES"
     }):
         config = widget.get_mce_config(attrs={"id": "id"})
         self.assertEqual(config["language"], "ru")
コード例 #2
0
 def test_language_override_from_config(self):
     """language in DEFAULT_CONFIG has priority over current Django language."""
     widget = TinyMCE()
     orig_config = tinymce.settings.DEFAULT_CONFIG
     with patch.dict(tinymce.settings.DEFAULT_CONFIG, {
             **orig_config, "language": "es_ES"
     }):
         config = widget.get_mce_config(attrs={"id": "id"})
         self.assertEqual(config["language"], "es_ES")
コード例 #3
0
ファイル: test_widgets.py プロジェクト: vincentmuya/scorpus
 def test_no_language_for_en_US(self):
     """
     en_US shouldn't set 'language'
     (https://github.com/tinymce/tinymce/issues/4228)
     """
     widget = TinyMCE()
     with override_settings(LANGUAGE_CODE="en-us"):
         config = widget.get_mce_config(attrs={"id": "id"})
         self.assertNotIn("language", config.keys())
     self.assertEqual(config["directionality"], "ltr")
コード例 #4
0
 def test_config_from_language_code(self):
     langs = [
         ("en", "en"),
         ("fr",
          "fr_FR"),  # Currently no "fr" language file exist for TinyMCE.
         ("de-ch", "de"),
         ("pt-br", "pt_BR"),
         ("he", "he_IL"),
         ("he_il", "he_IL"),
     ]
     widget = TinyMCE()
     for lang_code, lang_expected in langs:
         with override_settings(LANGUAGE_CODE=lang_code):
             config = widget.get_mce_config(attrs={"id": "id"})
             self.assertEqual(config["language"], lang_expected)
     # A language with no matching TinyMCE translation:
     expected = "No TinyMCE language found for 'kab', defaulting to 'en_US'"
     with self.assertWarnsRegex(RuntimeWarning, expected):
         with override_settings(LANGUAGE_CODE="kab"):
             config = widget.get_mce_config(attrs={"id": "id"})
             self.assertEqual(config["language"], "en_US")
コード例 #5
0
 def test_config_from_language_code(self):
     langs = [
         ("en", "en"),
         ("fr", "fr"),
         ("pt-br", "pt_BR"),
         ("sr-latn", "sr_Latn"),
     ]
     widget = TinyMCE()
     for lang_code, lang_expected in langs:
         with override_settings(LANGUAGE_CODE=lang_code):
             config = widget.get_mce_config(attrs={"id": "id"})
             self.assertEqual(config["language"], lang_expected)
コード例 #6
0
 def test_no_active_language(self):
     widget = TinyMCE()
     with override(None):
         config = widget.get_mce_config(attrs={"id": "id"})
         self.assertEqual(config["language"], "en_US")
         self.assertEqual(config["spellchecker_languages"], "+English=en")