-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace generic `combine` with specific `merge_dicts_deep`, `merge_dicts_shallow`, `merge_dicts_one_level` or `concat_lists`, depending on appropriate behavior for each message attribute. Fixes merging global `SEND_DEFAULTS` with message `esp_extra` for ESP APIs that use nested payload structures. And clarifies intent for other properties.
- Loading branch information
Showing
6 changed files
with
270 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,7 +209,10 @@ def test_esp_send_defaults(self): | |
"tags": ["globaltag"], | ||
"track_clicks": True, | ||
"track_opens": False, | ||
"esp_extra": {"globalextra": "globalsetting"}, | ||
"esp_extra": { | ||
"globalextra": "globalsetting", | ||
"deepextra": {"deep1": "globaldeep1", "deep2": "globaldeep2"}, | ||
}, | ||
} | ||
} | ||
) | ||
|
@@ -218,7 +221,10 @@ def test_send_defaults_combine_with_message(self): | |
self.message.metadata = {"message": "messagevalue", "other": "override"} | ||
self.message.tags = ["messagetag"] | ||
self.message.track_clicks = False | ||
self.message.esp_extra = {"messageextra": "messagesetting"} | ||
self.message.esp_extra = { | ||
"messageextra": "messagesetting", | ||
"deepextra": {"deep2": "messagedeep2", "deep3": "messagedeep3"}, | ||
} | ||
|
||
self.message.send() | ||
params = self.get_send_params() | ||
|
@@ -234,8 +240,13 @@ def test_send_defaults_combine_with_message(self): | |
self.assertEqual(params["tags"], ["globaltag", "messagetag"]) | ||
self.assertEqual(params["track_clicks"], False) # message overrides | ||
self.assertEqual(params["track_opens"], False) # (no message setting) | ||
# esp_extra is deep merged: | ||
self.assertEqual(params["globalextra"], "globalsetting") | ||
self.assertEqual(params["messageextra"], "messagesetting") | ||
self.assertEqual( | ||
params["deepextra"], | ||
{"deep1": "globaldeep1", "deep2": "messagedeep2", "deep3": "messagedeep3"}, | ||
) | ||
|
||
# Send another message to make sure original SEND_DEFAULTS unchanged | ||
send_mail("subject", "body", "[email protected]", ["[email protected]"]) | ||
|
@@ -247,6 +258,9 @@ def test_send_defaults_combine_with_message(self): | |
self.assertEqual(params["track_clicks"], True) | ||
self.assertEqual(params["track_opens"], False) | ||
self.assertEqual(params["globalextra"], "globalsetting") | ||
self.assertEqual( | ||
params["deepextra"], {"deep1": "globaldeep1", "deep2": "globaldeep2"} | ||
) | ||
|
||
@override_settings( | ||
ANYMAIL={ | ||
|
Oops, something went wrong.