Skip to content

Commit

Permalink
fix: add darklangmiddleware backend for test
Browse files Browse the repository at this point in the history
  • Loading branch information
MaferMazu committed Jun 22, 2023
1 parent 5594796 commit 3bc273e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
DarkLangMiddleware Backend for tests.
"""
from unittest.mock import MagicMock


def get_dark_lang_middleware():
"""Backend to get the DarkLangMiddleware from openedx."""
return MagicMock()
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from openedx.core.djangoapps.dark_lang.middleware import DarkLangMiddleware
"""
DarkLangMiddleware Backend.
"""
from openedx.core.djangoapps.dark_lang.middleware import DarkLangMiddleware # pylint: disable=import-error


def get_dark_lang_middleware():
"""Backend to get the DarkLangMiddleware from openedx."""
Expand Down
1 change: 1 addition & 0 deletions eox_tenant/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class SettingsClass:
GET_THEMING_HELPERS = 'eox_tenant.edxapp_wrapper.backends.theming_helpers_test_v1'
EOX_TENANT_USERS_BACKEND = 'eox_tenant.edxapp_wrapper.backends.users_test_v1'
EOX_TENANT_BEARER_AUTHENTICATION = 'eox_tenant.edxapp_wrapper.backends.bearer_authentication_test_v1'
DARK_LANG_MIDDLEWARE = 'eox_tenant.edxapp_wrapper.backends.dark_lang_middleware_o_test_v1'

COURSE_KEY_PATTERN = r'(?P<course_key_string>[^/+]+(/|\+)[^/+]+(/|\+)[^/?]+)'
COURSE_ID_PATTERN = COURSE_KEY_PATTERN.replace('course_key_string', 'course_id')
Expand Down
4 changes: 4 additions & 0 deletions eox_tenant/tenant_aware_functions/released_languages.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
"""
Site/Tenant aware languages filter.
"""
from collections import namedtuple

from django.conf import settings

Language = namedtuple('Language', 'code name')


def tenant_languages():
"""Retrieve the list of released languages by tenant.
Expand Down
2 changes: 1 addition & 1 deletion eox_tenant/tenant_wise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from django.conf import settings

from eox_tenant.constants import LMS_ENVIRONMENT
from eox_tenant.tenant_wise.proxies import TenantSiteConfigProxy, DarkLangMiddlewareProxy
from eox_tenant.tenant_aware_functions.released_languages import tenant_languages
from eox_tenant.tenant_wise.proxies import DarkLangMiddlewareProxy, TenantSiteConfigProxy


def load_tenant_wise_overrides():
Expand Down
11 changes: 5 additions & 6 deletions eox_tenant/tenant_wise/proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import six
from django.conf import settings
from django.core.cache import cache
from eox_tenant.edxapp_wrapper.dark_lang_middleware import \
get_dark_lang_middleware
from eox_tenant.edxapp_wrapper.site_configuration_module import \
get_site_configuration_models

from eox_tenant.edxapp_wrapper.dark_lang_middleware import get_dark_lang_middleware
from eox_tenant.edxapp_wrapper.site_configuration_module import get_site_configuration_models
from eox_tenant.models import Microsite, TenantConfig, TenantOrganization
from eox_tenant.utils import clean_serializable_values

Expand Down Expand Up @@ -215,12 +214,12 @@ def released_langs(self):
"""
Current list of released languages from settings.
"""

language_options = getattr(settings, "released_languages", "")
if settings.LANGUAGE_CODE not in language_options:
language_options.append(settings.LANGUAGE_CODE)
return language_options

def process_request(self, request):
"""
This will be run when you do a request, and prevent user from requesting un-released languages.
Expand Down

0 comments on commit 3bc273e

Please sign in to comment.