Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] add test for get_language_config
- Loading branch information
1 parent
1c612a4
commit 3085258
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import os | ||
import sys | ||
os.environ['DJANGO_SETTINGS_MODULE'] = 'testtinymce.settings' | ||
test_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
sys.path.insert(0, test_dir) | ||
|
||
from django.test.utils import get_runner | ||
from django.conf import settings | ||
import django | ||
if django.VERSION >= (1, 7): | ||
django.setup() | ||
|
||
|
||
def runtests(): | ||
TestRunner = get_runner(settings) | ||
test_runner = TestRunner(verbosity=1, interactive=True) | ||
failures = test_runner.run_tests(['tinymce']) | ||
sys.exit(bool(failures)) | ||
|
||
if __name__ == '__main__': | ||
runtests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# coding: utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# coding: utf-8 | ||
|
||
from django.test import TestCase, override_settings | ||
|
||
from tinymce.widgets import get_language_config | ||
|
||
|
||
@override_settings(LANGUAGES=[('en', 'English')]) | ||
class TestWidgets(TestCase): | ||
|
||
def test_default_config(self): | ||
config = get_language_config() | ||
config_ok = { | ||
'spellchecker_languages': '+English=en', | ||
'directionality': 'ltr', | ||
'language': 'en', | ||
'spellchecker_rpc_url': '/tinymce/spellchecker/' | ||
} | ||
self.assertEqual(config, config_ok) | ||
|
||
@override_settings(LANGUAGES_BIDI=['en']) | ||
def test_default_config_rtl(self): | ||
config = get_language_config() | ||
config_ok = { | ||
'spellchecker_languages': '+English=en', | ||
'directionality': 'rtl', | ||
'language': 'en', | ||
'spellchecker_rpc_url': '/tinymce/spellchecker/' | ||
} | ||
self.assertEqual(config, config_ok) | ||
|
||
def test_content_language(self): | ||
config = get_language_config('ru-ru') | ||
config_ok = { | ||
'spellchecker_languages': 'English=en', | ||
'directionality': 'ltr', | ||
'language': 'en', | ||
'spellchecker_rpc_url': '/tinymce/spellchecker/' | ||
} | ||
self.assertEqual(config, config_ok) |