SparkPost: drop support for multiple from_email (#213)

SparkPost's API no longer allows this, and now returns
a confusing error message about return_path.

(Not treating as a breaking change in Anymail, because
the breaking change was in the SparkPost API. This just
improves the error message in the unlikely event anyone
is trying to use this feature.)

Closes #212
This commit is contained in:
Mike Edmunds
2020-11-28 18:02:59 -08:00
committed by GitHub
parent a7ea862ff1
commit 8c1749c6f3
5 changed files with 30 additions and 22 deletions

View File

@@ -10,7 +10,7 @@ from django.test import override_settings, tag
from django.utils.timezone import get_fixed_timezone, override as override_current_timezone, utc
from anymail.exceptions import (
AnymailAPIError, AnymailConfigurationError, AnymailInvalidAddress, AnymailRecipientsRefused,
AnymailAPIError, AnymailConfigurationError, AnymailRecipientsRefused,
AnymailSerializationError, AnymailUnsupportedFeature)
from anymail.message import attach_inline_image_file
@@ -318,20 +318,6 @@ class SparkPostBackendStandardEmailTests(SparkPostBackendMockAPITestCase):
},
}])
def test_multiple_from_emails(self):
"""SparkPost supports multiple addresses in from_email"""
self.message.from_email = 'first@example.com, "From, also" <second@example.com>'
self.message.send()
data = self.get_api_call_json()
self.assertEqual(data["content"]["from"],
'first@example.com, "From, also" <second@example.com>')
# Make sure the far-more-likely scenario of a single from_email
# with an unquoted display-name issues a reasonable error:
self.message.from_email = 'Unquoted, display-name <from@example.com>'
with self.assertRaises(AnymailInvalidAddress):
self.message.send()
def test_api_failure(self):
self.set_mock_response(status_code=400)
with self.assertRaisesMessage(AnymailAPIError, "SparkPost API response 400"):