Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lms/djangoapps/mfe_config_api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,16 @@ def side_effect(key, default=None):
response = self.client.get(self.url)
data = response.json()

# Site-level key translated to top level
common = data["commonAppConfig"]
# Site-level keys are translated to top level
self.assertEqual(data["lmsBaseUrl"], "https://courses.example.com") # noqa: PT009
self.assertEqual(data["cmsBaseUrl"], "https://studio.example.com") # noqa: PT009
# Site-level keys translated to top level don't appear in commonAppConfig
self.assertNotIn("LMS_BASE_URL", common) # noqa: PT009
self.assertNotIn("STUDIO_BASE_URL", common) # noqa: PT009
# Unmapped MFE_CONFIG keys appear in commonAppConfig (not at the top level)
self.assertNotIn("CREDENTIALS_BASE_URL", data) # noqa: PT009
common = data["commonAppConfig"]
self.assertEqual(common["CREDENTIALS_BASE_URL"], "https://credentials.example.com") # noqa: PT009
self.assertEqual(common["STUDIO_BASE_URL"], "https://studio.example.com") # noqa: PT009
# Legacy config keys also appear in commonAppConfig
for legacy_key in default_legacy_config:
self.assertIn(legacy_key, common) # noqa: PT009
Expand Down Expand Up @@ -609,12 +612,13 @@ def side_effect(key, default=None):
response = self.client.get(self.url)
data = response.json()

# Site-level key is promoted to the top level
# Site-level keys are promoted to the top level
self.assertEqual(data["lmsBaseUrl"], "https://courses.example.com") # noqa: PT009
self.assertEqual(data["cmsBaseUrl"], "https://studio.example.com") # noqa: PT009
# Unmapped keys are preserved in commonAppConfig
common = data["commonAppConfig"]
self.assertEqual(common["CREDENTIALS_BASE_URL"], "https://credentials.example.com") # noqa: PT009
self.assertEqual(common["STUDIO_BASE_URL"], "https://studio.example.com") # noqa: PT009
self.assertNotIn("STUDIO_BASE_URL", common) # noqa: PT009
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment to my previous one, feels odd to be using assertNotIn on common in the "Unmapped keys are preserved in commonAppConfig" block


@patch("lms.djangoapps.mfe_config_api.views.get_legacy_config_overrides", return_value={})
@patch("lms.djangoapps.mfe_config_api.views.configuration_helpers")
Expand Down
1 change: 1 addition & 0 deletions lms/djangoapps/mfe_config_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"LOGIN_URL": "loginUrl",
"LOGOUT_URL": "logoutUrl",
# OptionalSiteConfig
"STUDIO_BASE_URL": "cmsBaseUrl",
"LOGO_URL": "headerLogoImageUrl",
"ACCESS_TOKEN_COOKIE_NAME": "accessTokenCookieName",
"LANGUAGE_PREFERENCE_COOKIE_NAME": "languagePreferenceCookieName",
Expand Down
Loading