Skip to content

Commit

Permalink
[Tests] add test for get_language_config
Browse files Browse the repository at this point in the history
  • Loading branch information
vanadium23 committed Feb 23, 2016
1 parent 1c612a4 commit 3085258
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
21 changes: 21 additions & 0 deletions runtests.py
@@ -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()
1 change: 1 addition & 0 deletions tinymce/tests/__init__.py
@@ -0,0 +1 @@
# coding: utf-8
40 changes: 40 additions & 0 deletions tinymce/tests/test_widgets.py
@@ -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)

0 comments on commit 3085258

Please sign in to comment.