-
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.
Unisender Go: Fix integrations bcc test and add unit test for cc/bcc
- Loading branch information
Showing
2 changed files
with
46 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,10 @@ def test_all_options(self): | |
), | ||
to=["[email protected]", '"Recipient 2, OK?" <[email protected]>'], | ||
cc=["[email protected]", '"Copy 2, OK?" <[email protected]>'], | ||
bcc=["[email protected]", '"BCC 2, OK?" <[email protected]>'], | ||
bcc=[ | ||
f"test+bcc1@{ANYMAIL_TEST_UNISENDER_GO_DOMAIN}", | ||
f'"BCC 2, OK?" <bcc2@{ANYMAIL_TEST_UNISENDER_GO_DOMAIN}>', | ||
], | ||
# Unisender Go only supports a single reply-to: | ||
reply_to=['"Reply, with comma (and parens)" <[email protected]>'], | ||
headers={"X-Anymail-Test": "value", "X-Anymail-Count": 3}, | ||
|
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from email.headerregistry import Address | ||
|
||
from django.test import SimpleTestCase, override_settings, tag | ||
from requests.structures import CaseInsensitiveDict | ||
|
||
from anymail.backends.unisender_go import EmailBackend, UnisenderGoPayload | ||
from anymail.message import AnymailMessage | ||
|
@@ -64,6 +65,47 @@ def test_unisender_go_payload__full(self): | |
|
||
self.assertEqual(payload.data, expected_payload) | ||
|
||
def test_unisender_go_payload__cc_bcc(self): | ||
cc_to_email = "[email protected]" | ||
bcc_to_email = "[email protected]" | ||
email = AnymailMessage( | ||
template_id=TEMPLATE_ID, | ||
subject=SUBJECT, | ||
merge_global_data=GLOBAL_DATA, | ||
from_email=f"{FROM_NAME} <{FROM_EMAIL}>", | ||
to=[ | ||
str(Address(display_name=TO_NAME, addr_spec=TO_EMAIL)), | ||
str(Address(display_name=OTHER_TO_NAME, addr_spec=OTHER_TO_EMAIL)), | ||
], | ||
cc=[cc_to_email], | ||
bcc=[bcc_to_email], | ||
) | ||
backend = EmailBackend() | ||
|
||
payload = UnisenderGoPayload( | ||
message=email, backend=backend, defaults=backend.send_defaults | ||
) | ||
expected_headers = { | ||
"To": f"{TO_NAME} <{TO_EMAIL}>, {OTHER_TO_NAME} <{OTHER_TO_EMAIL}>", | ||
"CC": cc_to_email, | ||
} | ||
expected_headers = CaseInsensitiveDict(expected_headers) | ||
expected_recipients = [ | ||
{ | ||
"email": TO_EMAIL, | ||
"substitutions": {"to_name": TO_NAME}, | ||
}, | ||
{ | ||
"email": OTHER_TO_EMAIL, | ||
"substitutions": {"to_name": OTHER_TO_NAME}, | ||
}, | ||
{"email": cc_to_email}, | ||
{"email": bcc_to_email}, | ||
] | ||
|
||
self.assertEqual(payload.data["headers"], expected_headers) | ||
self.assertCountEqual(payload.data["recipients"], expected_recipients) | ||
|
||
def test_unisender_go_payload__parse_from__with_name(self): | ||
email = AnymailMessage( | ||
subject=SUBJECT, | ||
|