diff options
| author | Ronny Vedrilla <ronny.vedrilla@ambient.digital> | 2024-06-20 11:03:32 +0200 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-06-21 12:00:56 +0200 |
| commit | 5fef6d2445509c2f071d06b348ca001be9e7ab05 (patch) | |
| tree | d68f368eacb534e3489928a2a472e643d3e4e2c1 /tests | |
| parent | 7a0cd09f9f85f55fdc2b3fe63bea94b21e31d3c2 (diff) | |
Fixed #35528 -- Added EmailMultiAlternatives.body_contains() helper method.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mail/tests.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/mail/tests.py b/tests/mail/tests.py index 3746ede338..1f7cbbadca 100644 --- a/tests/mail/tests.py +++ b/tests/mail/tests.py @@ -1163,6 +1163,24 @@ class MailTests(HeadersCheckMixin, SimpleTestCase): with self.assertRaisesMessage(ValueError, msg): email_msg.attach_alternative("<p>content</p>", None) + def test_body_contains(self): + email_msg = EmailMultiAlternatives() + email_msg.body = "I am content." + self.assertIs(email_msg.body_contains("I am"), True) + self.assertIs(email_msg.body_contains("I am content."), True) + + email_msg.attach_alternative("<p>I am different content.</p>", "text/html") + self.assertIs(email_msg.body_contains("I am"), True) + self.assertIs(email_msg.body_contains("I am content."), False) + self.assertIs(email_msg.body_contains("<p>I am different content.</p>"), False) + + def test_body_contains_alternative_non_text(self): + email_msg = EmailMultiAlternatives() + email_msg.body = "I am content." + email_msg.attach_alternative("I am content.", "text/html") + email_msg.attach_alternative(b"I am a song.", "audio/mpeg") + self.assertIs(email_msg.body_contains("I am content"), True) + @requires_tz_support class MailTimeZoneTests(SimpleTestCase): |
