refactor!: change the api naming and url
This commit is contained in:
2
.github/workflows/pylint-checks.yml
vendored
2
.github/workflows/pylint-checks.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
- module-name: lms-1
|
||||
path: "lms/djangoapps/badges/ lms/djangoapps/branding/ lms/djangoapps/bulk_email/ lms/djangoapps/bulk_enroll/ lms/djangoapps/bulk_user_retirement/ lms/djangoapps/ccx/ lms/djangoapps/certificates/ lms/djangoapps/commerce/ lms/djangoapps/course_api/ lms/djangoapps/course_blocks/ lms/djangoapps/course_home_api/ lms/djangoapps/course_wiki/ lms/djangoapps/coursewarehistoryextended/ lms/djangoapps/debug/ lms/djangoapps/courseware/ lms/djangoapps/course_goals/ lms/djangoapps/rss_proxy/ lms/djangoapps/save_for_later/"
|
||||
- module-name: lms-2
|
||||
path: "lms/djangoapps/gating/ lms/djangoapps/grades/ lms/djangoapps/instructor/ lms/djangoapps/instructor_analytics/ lms/djangoapps/discussion/ lms/djangoapps/edxnotes/ lms/djangoapps/email_marketing/ lms/djangoapps/experiments/ lms/djangoapps/instructor_task/ lms/djangoapps/learner_dashboard/ lms/djangoapps/lms_initialization/ lms/djangoapps/lms_xblock/ lms/djangoapps/lti_provider/ lms/djangoapps/mailing/ lms/djangoapps/mobile_api/ lms/djangoapps/monitoring/ lms/djangoapps/ora_staff_grader/ lms/djangoapps/program_enrollments/ lms/djangoapps/rss_proxy lms/djangoapps/static_template_view/ lms/djangoapps/staticbook/ lms/djangoapps/support/ lms/djangoapps/survey/ lms/djangoapps/teams/ lms/djangoapps/tests/ lms/djangoapps/user_tours/ lms/djangoapps/verify_student/ lms/djangoapps/mfe_api/ lms/envs/ lms/lib/ lms/tests.py"
|
||||
path: "lms/djangoapps/gating/ lms/djangoapps/grades/ lms/djangoapps/instructor/ lms/djangoapps/instructor_analytics/ lms/djangoapps/discussion/ lms/djangoapps/edxnotes/ lms/djangoapps/email_marketing/ lms/djangoapps/experiments/ lms/djangoapps/instructor_task/ lms/djangoapps/learner_dashboard/ lms/djangoapps/lms_initialization/ lms/djangoapps/lms_xblock/ lms/djangoapps/lti_provider/ lms/djangoapps/mailing/ lms/djangoapps/mobile_api/ lms/djangoapps/monitoring/ lms/djangoapps/ora_staff_grader/ lms/djangoapps/program_enrollments/ lms/djangoapps/rss_proxy lms/djangoapps/static_template_view/ lms/djangoapps/staticbook/ lms/djangoapps/support/ lms/djangoapps/survey/ lms/djangoapps/teams/ lms/djangoapps/tests/ lms/djangoapps/user_tours/ lms/djangoapps/verify_student/ lms/djangoapps/mfe_config_api/ lms/envs/ lms/lib/ lms/tests.py"
|
||||
- module-name: openedx-1
|
||||
path: "openedx/core/types/ openedx/core/djangoapps/ace_common/ openedx/core/djangoapps/agreements/ openedx/core/djangoapps/api_admin/ openedx/core/djangoapps/auth_exchange/ openedx/core/djangoapps/bookmarks/ openedx/core/djangoapps/cache_toolbox/ openedx/core/djangoapps/catalog/ openedx/core/djangoapps/ccxcon/ openedx/core/djangoapps/commerce/ openedx/core/djangoapps/common_initialization/ openedx/core/djangoapps/common_views/ openedx/core/djangoapps/config_model_utils/ openedx/core/djangoapps/content/ openedx/core/djangoapps/content_libraries/ openedx/core/djangoapps/contentserver/ openedx/core/djangoapps/cookie_metadata/ openedx/core/djangoapps/cors_csrf/ openedx/core/djangoapps/course_apps/ openedx/core/djangoapps/course_date_signals/ openedx/core/djangoapps/course_groups/ openedx/core/djangoapps/courseware_api/ openedx/core/djangoapps/crawlers/ openedx/core/djangoapps/credentials/ openedx/core/djangoapps/credit/ openedx/core/djangoapps/dark_lang/ openedx/core/djangoapps/debug/ openedx/core/djangoapps/demographics/ openedx/core/djangoapps/discussions/ openedx/core/djangoapps/django_comment_common/ openedx/core/djangoapps/embargo/ openedx/core/djangoapps/enrollments/ openedx/core/djangoapps/external_user_ids/ openedx/core/djangoapps/zendesk_proxy/ openedx/core/djangolib/ openedx/core/lib/ openedx/core/tests/ openedx/core/djangoapps/course_live/"
|
||||
- module-name: openedx-2
|
||||
|
||||
2
.github/workflows/unit-test-shards.json
vendored
2
.github/workflows/unit-test-shards.json
vendored
@@ -71,7 +71,7 @@
|
||||
"lms/djangoapps/tests/",
|
||||
"lms/djangoapps/user_tours/",
|
||||
"lms/djangoapps/verify_student/",
|
||||
"lms/djangoapps/mfe_api/",
|
||||
"lms/djangoapps/mfe_config_api/",
|
||||
"lms/envs/",
|
||||
"lms/lib/",
|
||||
"lms/tests.py"
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
""" URLs configuration for the mfe api."""
|
||||
|
||||
from django.urls import path
|
||||
|
||||
from lms.djangoapps.mfe_api.views import MFEConfigView
|
||||
|
||||
app_name = 'mfe_api'
|
||||
urlpatterns = [
|
||||
path('v1/config', MFEConfigView.as_view(), name='config'),
|
||||
]
|
||||
@@ -17,10 +17,10 @@ class MFEConfigTestCase(APITestCase):
|
||||
Test the use case that exposes the site configuration with the mfe api.
|
||||
"""
|
||||
def setUp(self):
|
||||
self.mfe_config_api_url = reverse("mfe_api:config")
|
||||
self.mfe_config_api_url = reverse("mfe_config_api:config")
|
||||
return super().setUp()
|
||||
|
||||
@patch("lms.djangoapps.mfe_api.views.configuration_helpers")
|
||||
@patch("lms.djangoapps.mfe_config_api.views.configuration_helpers")
|
||||
def test_get_mfe_config(self, configuration_helpers_mock):
|
||||
"""Test the get mfe config from site configuration with the mfe api.
|
||||
|
||||
@@ -37,7 +37,7 @@ class MFEConfigTestCase(APITestCase):
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.json(), {"EXAMPLE_VAR": "value"})
|
||||
|
||||
@patch("lms.djangoapps.mfe_api.views.configuration_helpers")
|
||||
@patch("lms.djangoapps.mfe_config_api.views.configuration_helpers")
|
||||
def test_get_mfe_config_with_queryparam(self, configuration_helpers_mock):
|
||||
"""Test the get mfe config with a query param from site configuration.
|
||||
|
||||
@@ -56,7 +56,7 @@ class MFEConfigTestCase(APITestCase):
|
||||
configuration_helpers_mock.get_value.assert_has_calls(calls)
|
||||
self.assertEqual(response.json(), {"EXAMPLE_VAR": "mymfe_value", "OTHER": "other"})
|
||||
|
||||
@patch("lms.djangoapps.mfe_api.views.configuration_helpers")
|
||||
@patch("lms.djangoapps.mfe_config_api.views.configuration_helpers")
|
||||
@ddt.data(
|
||||
[{}, {}, {}],
|
||||
[{"EXAMPLE_VAR": "value"}, {}, {"EXAMPLE_VAR": "value"}],
|
||||
@@ -93,8 +93,8 @@ class MFEConfigTestCase(APITestCase):
|
||||
configuration_helpers_mock.get_value.assert_has_calls(calls)
|
||||
self.assertEqual(response.json(), expected_response)
|
||||
|
||||
@patch("lms.djangoapps.mfe_api.views.configuration_helpers")
|
||||
@override_settings(ENABLE_MFE_API=False)
|
||||
@patch("lms.djangoapps.mfe_config_api.views.configuration_helpers")
|
||||
@override_settings(ENABLE_MFE_CONFIG_API=False)
|
||||
def test_404_get_mfe_config(self, configuration_helpers_mock):
|
||||
"""Test the 404 not found response from get mfe config.
|
||||
|
||||
10
lms/djangoapps/mfe_config_api/urls.py
Normal file
10
lms/djangoapps/mfe_config_api/urls.py
Normal file
@@ -0,0 +1,10 @@
|
||||
""" URLs configuration for the mfe api."""
|
||||
|
||||
from django.urls import path
|
||||
|
||||
from lms.djangoapps.mfe_config_api.views import MFEConfigView
|
||||
|
||||
app_name = 'mfe_config_api'
|
||||
urlpatterns = [
|
||||
path('', MFEConfigView.as_view(), name='config'),
|
||||
]
|
||||
@@ -17,12 +17,12 @@ class MFEConfigView(APIView):
|
||||
Provides an API endpoint to get the MFE_CONFIG from site configuration.
|
||||
"""
|
||||
|
||||
@method_decorator(cache_page(settings.MFE_API_CONFIG_CACHE_TIMEOUT))
|
||||
@method_decorator(cache_page(settings.MFE_CONFIG_API_CACHE_TIMEOUT))
|
||||
def get(self, request):
|
||||
"""
|
||||
GET /api/mfe/v1/config
|
||||
GET /api/v1/mfe_config
|
||||
or
|
||||
GET /api/mfe/v1/config?mfe=name_of_mfe
|
||||
GET /api/v1/mfe_config?mfe=name_of_mfe
|
||||
|
||||
**GET Response Values**
|
||||
```
|
||||
@@ -40,7 +40,7 @@ class MFEConfigView(APIView):
|
||||
```
|
||||
"""
|
||||
|
||||
if not settings.ENABLE_MFE_API:
|
||||
if not settings.ENABLE_MFE_CONFIG_API:
|
||||
return HttpResponseNotFound()
|
||||
|
||||
mfe_config = configuration_helpers.get_value('MFE_CONFIG', {})
|
||||
@@ -3253,7 +3253,7 @@ INSTALLED_APPS = [
|
||||
'blockstore.apps.bundles',
|
||||
|
||||
# MFE API
|
||||
'lms.djangoapps.mfe_api',
|
||||
'lms.djangoapps.mfe_config_api',
|
||||
]
|
||||
|
||||
######################### CSRF #########################################
|
||||
@@ -5143,7 +5143,7 @@ COURSE_LIVE_GLOBAL_CREDENTIALS = {}
|
||||
|
||||
PERSONALIZED_RECOMMENDATION_COOKIE_NAME = 'edx-user-personalized-recommendation'
|
||||
|
||||
# .. toggle_name: ENABLE_MFE_API
|
||||
# .. toggle_name: ENABLE_MFE_CONFIG_API
|
||||
# .. toggle_implementation: DjangoSetting
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Set to True to enable MFE Config REST API. This is disabled by
|
||||
@@ -5153,10 +5153,10 @@ PERSONALIZED_RECOMMENDATION_COOKIE_NAME = 'edx-user-personalized-recommendation'
|
||||
# .. toggle_target_removal_date: None
|
||||
# .. toggle_warnings: None
|
||||
# .. toggle_tickets: None
|
||||
ENABLE_MFE_API = False
|
||||
ENABLE_MFE_CONFIG_API = False
|
||||
|
||||
# .. setting_name: MFE_API_CONFIG_CACHE_TIMEOUT
|
||||
# .. setting_name: MFE_CONFIG_API_CACHE_TIMEOUT
|
||||
# .. setting_default: 60*5
|
||||
# .. setting_description: The MFE_CONFIG site configuration will be cached during the
|
||||
# specified time
|
||||
MFE_API_CONFIG_CACHE_TIMEOUT = 60 * 5
|
||||
MFE_CONFIG_API_CACHE_TIMEOUT = 60 * 5
|
||||
|
||||
@@ -649,4 +649,4 @@ COURSE_LIVE_GLOBAL_CREDENTIALS["BIG_BLUE_BUTTON"] = {
|
||||
}
|
||||
|
||||
################## MFE API ####################
|
||||
ENABLE_MFE_API = True
|
||||
ENABLE_MFE_CONFIG_API = True
|
||||
|
||||
@@ -1025,5 +1025,5 @@ urlpatterns += [
|
||||
|
||||
# MFE API urls
|
||||
urlpatterns += [
|
||||
path('api/mfe/', include(('lms.djangoapps.mfe_api.urls', 'lms.djangoapps.mfe_api'), namespace='mfe_api'))
|
||||
path('api/v1/mfe_config', include(('lms.djangoapps.mfe_config_api.urls', 'lms.djangoapps.mfe_config_api'), namespace='mfe_config_api'))
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user