Skip to content

Commit a3decc9

Browse files
committed
Merge pull request #2989 from getsentry/aliases
Apply mail.backend aliases before escalating into settings
1 parent e170df3 commit a3decc9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/sentry/runner/initializer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ def bootstrap_options(settings, config=None):
140140
for o in (settings.SENTRY_DEFAULT_OPTIONS, settings.SENTRY_OPTIONS):
141141
for k, v in o.iteritems():
142142
if k in options_mapper:
143+
# Map the mail.backend aliases to something Django understands
144+
if k == 'mail.backend':
145+
try:
146+
v = settings.SENTRY_EMAIL_BACKEND_ALIASES[v]
147+
except KeyError:
148+
pass
143149
# Escalate the few needed to actually get the app bootstrapped into settings
144150
setattr(settings, options_mapper[k], v)
145151

tests/sentry/runner/test_initializer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Settings(object):
1616
s.SENTRY_FEATURES = {}
1717
s.SENTRY_OPTIONS = {}
1818
s.SENTRY_DEFAULT_OPTIONS = {}
19+
s.SENTRY_EMAIL_BACKEND_ALIASES = {'dummy': 'alias-for-dummy'}
1920
return s
2021

2122

@@ -138,6 +139,14 @@ def test_bootstrap_options_no_config_only_sentry_options(settings):
138139
assert settings.EMAIL_SUBJECT_PREFIX == 'my-mail-subject-prefix'
139140

140141

142+
def test_bootstrap_options_mail_aliases(settings):
143+
settings.SENTRY_OPTIONS = {
144+
'mail.backend': 'dummy',
145+
}
146+
bootstrap_options(settings)
147+
assert settings.EMAIL_BACKEND == 'alias-for-dummy'
148+
149+
141150
def test_bootstrap_options_missing_file(settings):
142151
bootstrap_options(settings, 'this-file-does-not-exist-xxxxxxxxxxxxxx.yml')
143152
assert settings.SENTRY_OPTIONS == {}

0 commit comments

Comments
 (0)