Allow kwargs overrides for (nearly) all settings

* Update utils.get_anymail_setting to support
  kwargs override of django.conf.settings values
* Use the updated version everywhere
* Switch from ImproperlyConfigured to
  AnymailConfigurationError exception
  (anticipates feature_wehooks change)

Closes #12
This commit is contained in:
medmunds
2016-04-29 14:34:34 -07:00
parent 6b415eeaae
commit df881fdb75
10 changed files with 124 additions and 38 deletions

View File

@@ -14,8 +14,10 @@ class MandrillBackend(AnymailRequestsBackend):
def __init__(self, **kwargs):
"""Init options from Django settings"""
self.api_key = get_anymail_setting('MANDRILL_API_KEY', allow_bare=True)
api_url = get_anymail_setting("MANDRILL_API_URL", "https://mandrillapp.com/api/1.0")
esp_name = self.esp_name
self.api_key = get_anymail_setting('api_key', esp_name=esp_name, kwargs=kwargs, allow_bare=True)
api_url = get_anymail_setting('api_url', esp_name=esp_name, kwargs=kwargs,
default="https://mandrillapp.com/api/1.0")
if not api_url.endswith("/"):
api_url += "/"
super(MandrillBackend, self).__init__(api_url, **kwargs)