From f114399e126557471496042869a21bd76ffe3e16 Mon Sep 17 00:00:00 2001 From: Daniel Wong Date: Tue, 17 Jun 2025 12:17:56 -0600 Subject: [PATCH] fix: update resolve_storage_backend function and fix tests --- cms/djangoapps/contentstore/tests/test_import.py | 1 - cms/djangoapps/export_course_metadata/test_signals.py | 1 - lms/djangoapps/verify_student/models.py | 7 +++---- lms/djangoapps/verify_student/tests/test_models.py | 1 + lms/djangoapps/verify_student/tests/test_views.py | 1 + openedx/core/djangoapps/content/block_structure/models.py | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_import.py b/cms/djangoapps/contentstore/tests/test_import.py index 697d829e54..1f6b393adc 100644 --- a/cms/djangoapps/contentstore/tests/test_import.py +++ b/cms/djangoapps/contentstore/tests/test_import.py @@ -308,7 +308,6 @@ class ContentStoreImportTest(ModuleStoreTestCase): @override_settings() def test_resolve_storage_with_no_config(self): """ If no storage setup is defined, we get FileSystemStorage by default """ - del settings.DEFAULT_FILE_STORAGE del settings.COURSE_IMPORT_EXPORT_STORAGE del settings.COURSE_IMPORT_EXPORT_BUCKET storage = resolve_storage_backend( diff --git a/cms/djangoapps/export_course_metadata/test_signals.py b/cms/djangoapps/export_course_metadata/test_signals.py index 0e2f1c0923..de3aaf6df2 100644 --- a/cms/djangoapps/export_course_metadata/test_signals.py +++ b/cms/djangoapps/export_course_metadata/test_signals.py @@ -84,7 +84,6 @@ class TestExportCourseMetadata(SharedModuleStoreTestCase): @override_settings() def test_resolve_storage_with_no_config(self): """ If no storage setup is defined, we get FileSystemStorage by default """ - del settings.DEFAULT_FILE_STORAGE del settings.COURSE_METADATA_EXPORT_STORAGE del settings.COURSE_METADATA_EXPORT_BUCKET storage = resolve_storage_backend( diff --git a/lms/djangoapps/verify_student/models.py b/lms/djangoapps/verify_student/models.py index a483d765d0..a0bed6444d 100644 --- a/lms/djangoapps/verify_student/models.py +++ b/lms/djangoapps/verify_student/models.py @@ -914,7 +914,6 @@ class SoftwareSecurePhotoVerification(PhotoVerification): config = settings.VERIFY_STUDENT["SOFTWARE_SECURE"] # Default to the S3 backend for backward compatibility - storage_class = config.get("STORAGE_CLASS", "storages.backends.s3boto3.S3Boto3Storage") storage_kwargs = config.get("STORAGE_KWARGS", {}) # Map old settings to the parameters expected by the storage backend @@ -927,9 +926,9 @@ class SoftwareSecurePhotoVerification(PhotoVerification): storage_kwargs["querystring_expire"] = self.IMAGE_LINK_DURATION return resolve_storage_backend( - storage_key="software_secure", - legacy_setting_key="SOFTWARE_SECURE", - legacy_sec_setting_key="STORAGE_CLASS", + storage_key="verify_student", + legacy_setting_key="VERIFY_STUDENT", + legacy_sec_setting_keys=["STORAGE_CLASS"], options=storage_kwargs ) diff --git a/lms/djangoapps/verify_student/tests/test_models.py b/lms/djangoapps/verify_student/tests/test_models.py index dfea8081e4..3ac603eaab 100644 --- a/lms/djangoapps/verify_student/tests/test_models.py +++ b/lms/djangoapps/verify_student/tests/test_models.py @@ -47,6 +47,7 @@ iwIDAQAB "CERT_VERIFICATION_PATH": False, }, "DAYS_GOOD_FOR": 10, + "STORAGE_CLASS": "storages.backends.s3boto3.S3Boto3Storage" } diff --git a/lms/djangoapps/verify_student/tests/test_views.py b/lms/djangoapps/verify_student/tests/test_views.py index 77ee515d37..d883a24a19 100644 --- a/lms/djangoapps/verify_student/tests/test_views.py +++ b/lms/djangoapps/verify_student/tests/test_views.py @@ -1301,6 +1301,7 @@ class TestSubmitPhotosForVerification(MockS3Boto3Mixin, TestVerificationBase): "CERT_VERIFICATION_PATH": False, }, "DAYS_GOOD_FOR": 10, + "STORAGE_CLASS": "storages.backends.s3boto3.S3Boto3Storage" }) @httpretty.activate def test_submit_photos_for_reverification(self): diff --git a/openedx/core/djangoapps/content/block_structure/models.py b/openedx/core/djangoapps/content/block_structure/models.py index 9099f83274..9bd75cab22 100644 --- a/openedx/core/djangoapps/content/block_structure/models.py +++ b/openedx/core/djangoapps/content/block_structure/models.py @@ -86,7 +86,7 @@ def _bs_model_storage(): return resolve_storage_backend( storage_key="block_structures_settings", legacy_setting_key="BLOCK_STRUCTURES_SETTINGS", - legacy_sec_setting_key="STORAGE_CLASS", + legacy_sec_setting_keys=["STORAGE_CLASS"], options=storage_kwargs )