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 f60f463
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 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
4 changes: 2 additions & 2 deletions eox_tenant/tenant_wise/proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,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 f60f463

Please sign in to comment.