Exemplo n.º 1
0
# -*- coding: utf-8 -*-
""" Tests for the language API. """

from __future__ import absolute_import

import ddt
from django.contrib.auth.models import User
from django.test.utils import override_settings
from django.utils import translation
from mock import patch
from openedx.core.djangoapps.dark_lang.models import DarkLangConfig
from openedx.core.djangoapps.lang_pref import api as language_api
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration_context
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase

EN = language_api.Language('en', 'English')
ES_419 = language_api.Language('es-419', u'Español (Latinoamérica)')
LT_LT = language_api.Language('lt-lt', u'Lietuvių (Lietuva)')


@ddt.ddt
class LanguageApiTest(CacheIsolationTestCase):
    """
    Tests of the language APIs.
    """
    @ddt.data(
        # Should return the base config value
        ({
            'SHOW_HEADER_LANGUAGE_SELECTOR': True
        }, {}, True),
# -*- coding: utf-8 -*-
""" Tests for the language API. """

from mock import patch
from django.test import TestCase
from django.test.utils import override_settings
from django.utils import translation
from django.contrib.auth.models import User
import ddt

from openedx.core.djangoapps.dark_lang.models import DarkLangConfig
from openedx.core.djangoapps.lang_pref import api as language_api
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration_context

EN = language_api.Language('en', 'English')
ES_419 = language_api.Language('es-419', u'Español (Latinoamérica)')


@ddt.ddt
class LanguageApiTest(TestCase):
    """
    Tests of the language APIs.
    """

    @ddt.data(
        # Should return the base config value
        ({'SHOW_HEADER_LANGUAGE_SELECTOR': True}, {}, True),

        # Should return the site config value
        ({'SHOW_HEADER_LANGUAGE_SELECTOR': False}, {'SHOW_HEADER_LANGUAGE_SELECTOR': True}, True),
        ({'SHOW_HEADER_LANGUAGE_SELECTOR': True}, {'SHOW_HEADER_LANGUAGE_SELECTOR': False}, False),