fix: log warning when INSTRUCTOR_MICROFRONTEND_URL is unset (#38000)
This commit is contained in:
@@ -494,6 +494,25 @@ class CourseMetadataViewTest(SharedModuleStoreTestCase):
|
||||
self.assertIn('course_errors', response.data)
|
||||
self.assertIsInstance(response.data['course_errors'], list)
|
||||
|
||||
@patch('lms.djangoapps.instructor.views.serializers_v2.settings.INSTRUCTOR_MICROFRONTEND_URL', None)
|
||||
def test_tabs_log_warning_when_mfe_url_not_set(self):
|
||||
"""
|
||||
Test that a warning is logged when INSTRUCTOR_MICROFRONTEND_URL is not set.
|
||||
"""
|
||||
with self.assertLogs('lms.djangoapps.instructor.views.serializers_v2', level='WARNING') as cm:
|
||||
tabs = self._get_tabs_from_response(self.staff)
|
||||
|
||||
self.assertTrue(
|
||||
any('INSTRUCTOR_MICROFRONTEND_URL is not set' in msg for msg in cm.output)
|
||||
)
|
||||
# Tab URLs should use empty string as base, not "None"
|
||||
for tab in tabs:
|
||||
self.assertFalse(tab['url'].startswith('None'), f"Tab URL should not start with 'None': {tab['url']}")
|
||||
self.assertTrue(
|
||||
tab['url'].startswith('/instructor/'),
|
||||
f"Tab URL should start with '/instructor/': {tab['url']}"
|
||||
)
|
||||
|
||||
def test_pacing_self_for_self_paced_course(self):
|
||||
"""
|
||||
Test that pacing is 'self' for self-paced courses.
|
||||
|
||||
@@ -5,6 +5,8 @@ These serializers handle data validation and business logic for instructor dashb
|
||||
Following REST best practices, serializers encapsulate most of the data processing logic.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.html import escape
|
||||
from django.utils.translation import gettext as _
|
||||
@@ -33,6 +35,8 @@ from xmodule.modulestore.django import modulestore
|
||||
|
||||
from .tools import get_student_from_identifier, parse_datetime, DashboardError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CourseInformationSerializerV2(serializers.Serializer):
|
||||
"""
|
||||
@@ -79,6 +83,10 @@ class CourseInformationSerializerV2(serializers.Serializer):
|
||||
course_key = course.id
|
||||
mfe_base_url = settings.INSTRUCTOR_MICROFRONTEND_URL
|
||||
|
||||
if not mfe_base_url:
|
||||
log.warning('INSTRUCTOR_MICROFRONTEND_URL is not set.')
|
||||
mfe_base_url = ''
|
||||
|
||||
access = {
|
||||
'admin': request.user.is_staff,
|
||||
'instructor': bool(has_access(request.user, 'instructor', course)),
|
||||
|
||||
@@ -398,6 +398,7 @@ COMMUNICATIONS_MICROFRONTEND_URL = 'http://localhost:1984'
|
||||
AUTHN_MICROFRONTEND_URL = 'http://localhost:1999'
|
||||
AUTHN_MICROFRONTEND_DOMAIN = 'localhost:1999'
|
||||
EXAMS_DASHBOARD_MICROFRONTEND_URL = 'http://localhost:2020'
|
||||
INSTRUCTOR_MICROFRONTEND_URL = 'http://localhost:2003'
|
||||
CATALOG_MICROFRONTEND_URL = 'http://localhost:1998/catalog'
|
||||
|
||||
################### FRONTEND APPLICATION DISCUSSIONS ###################
|
||||
|
||||
Reference in New Issue
Block a user