File tree Expand file tree Collapse file tree 5 files changed +43
-20
lines changed
Expand file tree Collapse file tree 5 files changed +43
-20
lines changed Original file line number Diff line number Diff line change 457457EXTRA_APPS = []
458458SESSION_EXPIRE_AT_BROWSER_CLOSE = False
459459STORAGES = {
460- "default" : {"BACKEND" : "django.core.files.storage.FileSystemStorage" },
461- "staticfiles" : {"BACKEND" : "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" },
460+ "default" : {
461+ "BACKEND" : "django.core.files.storage.FileSystemStorage" ,
462+ },
463+ "staticfiles" : {
464+ "BACKEND" : "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" ,
465+ },
462466}
463467CACHES = {
464468 "default" : {
Original file line number Diff line number Diff line change 4343EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
4444EMAIL_FILE_PATH = "/tmp/credentials-emails"
4545
46- STORAGES ["default" ]["BACKEND" ] = os .environ .get (
47- STORAGES ["default" ]["BACKEND" ], "django.core.files.storage.FileSystemStorage"
48- )
49- MEDIA_URL = os .environ .get ("MEDIA_URL" , "/media/" )
46+ STORAGES = {
47+ "default" : {
48+ "BACKEND" : "django.core.files.storage.FileSystemStorage" ,
49+ },
50+ "staticfiles" : {
51+ "BACKEND" : "django.contrib.staticfiles.storage.StaticFilesStorage" ,
52+ },
53+ }
5054
51- STORAGES [ "staticfiles" ][ "BACKEND" ] = "django.contrib.staticfiles.storage.StaticFilesStorage"
55+ MEDIA_URL = os . environ . get ( "MEDIA_URL" , "/media/" )
5256STATIC_URL = os .environ .get ("STATIC_URL" , "/static/" )
5357
5458# OAuth2 variables specific to social-auth/SSO login use case.
Original file line number Diff line number Diff line change 2323# be here as a default.
2424FILE_STORAGE_BACKEND = {}
2525
26+ STORAGES = {}
27+
2628EMAIL_BACKEND = "django_ses.SESBackend"
2729AWS_SES_REGION_NAME = environ .get ("AWS_SES_REGION_NAME" , "us-east-1" )
2830AWS_SES_REGION_ENDPOINT = environ .get ("AWS_SES_REGION_ENDPOINT" , "email.us-east-1.amazonaws.com" )
4345 vars ()[key ].update (value )
4446
4547 if "DEFAULT_FILE_STORAGE" in config_from_yaml :
46- STORAGES ["default" ] = {"BACKEND" : config_from_yaml .pop ("DEFAULT_FILE_STORAGE" )}
47- vars ().update (STORAGES )
48+ STORAGES .update ({
49+ "default" : {
50+ "BACKEND" : config_from_yaml .pop ("DEFAULT_FILE_STORAGE" )
51+ }
52+ })
4853
4954 if "STATICFILES_STORAGE" in config_from_yaml :
50- STORAGES ["staticfiles" ] = {"BACKEND" : config_from_yaml .pop ("STATICFILES_STORAGE" )}
51- vars ().update (STORAGES )
55+ STORAGES .update ({
56+ "staticfiles" : {
57+ "BACKEND" : config_from_yaml .pop ("STATICFILES_STORAGE" )
58+ }
59+ })
5260
5361 vars ().update (config_from_yaml )
5462
5563 if "DEFAULT_FILE_STORAGE" in FILE_STORAGE_BACKEND :
56- FILE_STORAGE_BACKEND ["STORAGES" ] = {"default" : {"BACKEND" : FILE_STORAGE_BACKEND .pop ("DEFAULT_FILE_STORAGE" )}}
57-
58- # Load the files storage backend settings for django storages
59- vars ().update (FILE_STORAGE_BACKEND )
64+ FILE_STORAGE_BACKEND .update ({
65+ "STORAGES" : {
66+ "default" : {"BACKEND" : FILE_STORAGE_BACKEND .pop ("DEFAULT_FILE_STORAGE" )}
67+ }
68+ })
6069
6170# make sure this happens after the configuration file overrides so format string can be overridden
6271LOGGING = get_logger_config (format_string = LOGGING_FORMAT_STRING )
Original file line number Diff line number Diff line change 3535
3636# Local Directories
3737TEST_ROOT = path ("test_root" )
38- STORAGES ["default" ]["BACKEND" ] = os .environ .get (
39- STORAGES ["default" ]["BACKEND" ], "django.core.files.storage.FileSystemStorage"
40- )
38+
39+ STORAGES = {
40+ "default" : {
41+ "BACKEND" : "django.core.files.storage.FileSystemStorage" ,
42+ },
43+ "staticfiles" : {
44+ "BACKEND" : "django.contrib.staticfiles.storage.StaticFilesStorage" ,
45+ },
46+ }
47+
4148MEDIA_ROOT = str (TEST_ROOT / "uploads" )
4249MEDIA_URL = "/static/uploads/"
4350
5158 "JWT_AUDIENCE" : SOCIAL_AUTH_EDX_OAUTH2_KEY ,
5259 }
5360)
54- STORAGES ["staticfiles" ]["BACKEND" ] = "django.contrib.staticfiles.storage.StaticFilesStorage"
5561
5662# Verifiable Credentials
5763ENABLE_VERIFIABLE_CREDENTIALS = True
Original file line number Diff line number Diff line change 66
77
88def test_production_storage_from_yaml (monkeypatch ):
9- """Test that YAML config correctly populates STORAGES and FILE_STORAGE_BACKEND ."""
9+ """Test that YAML config correctly populates STORAGES without leaking globals ."""
1010
1111 def fake_get_env_setting (key ):
1212 if key == "CREDENTIALS_CFG" :
You can’t perform that action at this time.
0 commit comments