-
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.
Use job_id as message_id if generation disabled
When not generating unique per-recipient message ids, use Unisender Go's "job_id" as Anymail's `message_id` for all recipients. The same job_id is provided in the send API response and tracking webhooks.
- Loading branch information
Showing
4 changed files
with
26 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -697,10 +697,23 @@ def test_rejected_recipient_status(self): | |
|
||
@override_settings(ANYMAIL_UNISENDER_GO_GENERATE_MESSAGE_ID=False) | ||
def test_disable_generate_message_id(self): | ||
""" | ||
When not generating per-recipient message_id, | ||
use Unisender Go's job_id for all recipients. | ||
""" | ||
self.set_mock_response( | ||
success_emails=["[email protected]", "[email protected]"], | ||
job_id="123456-000HHH-CcCc", | ||
) | ||
self.message.to = ["[email protected]", "[email protected]"] | ||
self.message.send() | ||
self.assertIsNone(self.message.anymail_status.message_id) | ||
self.assertIsNone( | ||
self.message.anymail_status.recipients["[email protected]"].message_id | ||
self.assertEqual(self.message.anymail_status.message_id, "123456-000HHH-CcCc") | ||
recipient_status = self.message.anymail_status.recipients | ||
self.assertEqual( | ||
recipient_status["[email protected]"].message_id, "123456-000HHH-CcCc" | ||
) | ||
self.assertEqual( | ||
recipient_status["[email protected]"].message_id, "123456-000HHH-CcCc" | ||
) | ||
|
||
# noinspection PyUnresolvedReferences | ||
|
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
EVENT_TYPE = EventType.SENT | ||
EVENT_TIME = "2015-11-30 15:09:42" | ||
EVENT_DATETIME = datetime.datetime(2015, 11, 30, 15, 9, 42, tzinfo=timezone.utc) | ||
MESSAGE_ID = "1a3Q2V-0000OZ-S0" | ||
JOB_ID = "1a3Q2V-0000OZ-S0" | ||
DELIVERY_RESPONSE = "550 Spam rejected" | ||
UNISENDER_TEST_EMAIL = "[email protected]" | ||
TEST_API_KEY = "api_key" | ||
|
@@ -30,7 +30,7 @@ | |
{ | ||
"event_name": "transactional_email_status", | ||
"event_data": { | ||
"job_id": MESSAGE_ID, | ||
"job_id": JOB_ID, | ||
"metadata": {"key1": "val1", "anymail_id": TEST_EMAIL_ID}, | ||
"email": UNISENDER_TEST_EMAIL, | ||
"status": EVENT_TYPE, | ||
|
@@ -69,7 +69,7 @@ | |
{ | ||
"event_name": "transactional_email_status", | ||
"event_data": { | ||
"job_id": MESSAGE_ID, | ||
"job_id": JOB_ID, | ||
"metadata": {}, | ||
"email": UNISENDER_TEST_EMAIL, | ||
"status": EVENT_TYPE, | ||
|
@@ -123,6 +123,9 @@ def test_without_delivery_info(self): | |
events = view.parse_events(request) | ||
|
||
self.assertEqual(len(events), 1) | ||
# Without metadata["anymail_id"], message_id uses the job_id. | ||
# (This covers messages sent with "UNISENDER_GO_GENERATE_MESSAGE_ID": False.) | ||
self.assertEqual(events[0].message_id, JOB_ID) | ||
|
||
@override_settings(ANYMAIL_UNISENDER_GO_API_KEY=TEST_API_KEY) | ||
def test_check_authorization(self): | ||
|