mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Deprecate DjrillMessage
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
from django.core.mail import EmailMultiAlternatives
|
from django.core.mail import EmailMultiAlternatives
|
||||||
|
|
||||||
|
from djrill.exceptions import removed_in_djrill_2
|
||||||
|
|
||||||
|
|
||||||
# DjrillMessage class is deprecated as of 0.2.0, but retained for
|
# DjrillMessage class is deprecated as of 0.2.0, but retained for
|
||||||
# compatibility with existing code. (New code can just set Mandrill-specific
|
# compatibility with existing code. (New code can just set Mandrill-specific
|
||||||
@@ -12,6 +14,11 @@ class DjrillMessage(EmailMultiAlternatives):
|
|||||||
cc=None, from_name=None, tags=None, track_opens=True,
|
cc=None, from_name=None, tags=None, track_opens=True,
|
||||||
track_clicks=True, preserve_recipients=None):
|
track_clicks=True, preserve_recipients=None):
|
||||||
|
|
||||||
|
removed_in_djrill_2(
|
||||||
|
"DjrillMessage will be removed in Djrill 2.0. "
|
||||||
|
"Use django.core.mail.EmailMultiAlternatives instead."
|
||||||
|
)
|
||||||
|
|
||||||
super(DjrillMessage, self).__init__(subject, body, from_email, to, bcc,
|
super(DjrillMessage, self).__init__(subject, body, from_email, to, bcc,
|
||||||
connection, attachments, headers, alternatives, cc)
|
connection, attachments, headers, alternatives, cc)
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from django.core import mail
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from djrill import MandrillAPIError, NotSupportedByMandrillError, DjrillAdminSite
|
from djrill import MandrillAPIError, NotSupportedByMandrillError, DjrillAdminSite
|
||||||
|
from djrill.exceptions import RemovedInDjrill2
|
||||||
from djrill.mail import DjrillMessage
|
from djrill.mail import DjrillMessage
|
||||||
from djrill.tests.mock_backend import DjrillBackendMockAPITestCase
|
from djrill.tests.mock_backend import DjrillBackendMockAPITestCase
|
||||||
from djrill.tests.utils import reset_warning_registry
|
from djrill.tests.utils import reset_warning_registry
|
||||||
@@ -42,6 +43,13 @@ class DjrillBackendDeprecationTests(DjrillBackendMockAPITestCase):
|
|||||||
self.assertEqual(data['message']['global_merge_vars'],
|
self.assertEqual(data['message']['global_merge_vars'],
|
||||||
[{'name': 'DATE', 'content': "2022-10-11 00:00:00"}])
|
[{'name': 'DATE', 'content': "2022-10-11 00:00:00"}])
|
||||||
|
|
||||||
|
def test_deprecated_djrill_message_class(self):
|
||||||
|
"""Djrill 0.2 deprecated DjrillMessage; 2.0 will drop it"""
|
||||||
|
self.assertWarnsMessage(DeprecationWarning,
|
||||||
|
"DjrillMessage will be removed in Djrill 2.0",
|
||||||
|
DjrillMessage)
|
||||||
|
|
||||||
|
|
||||||
def assertWarnsMessage(self, warning, message, callable, *args, **kwds):
|
def assertWarnsMessage(self, warning, message, callable, *args, **kwds):
|
||||||
"""Checks that `callable` issues a warning of category `warning` containing `message`"""
|
"""Checks that `callable` issues a warning of category `warning` containing `message`"""
|
||||||
with warnings.catch_warnings(record=True) as warned:
|
with warnings.catch_warnings(record=True) as warned:
|
||||||
@@ -69,6 +77,12 @@ class DjrillMessageTests(TestCase):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def run(self, result=None):
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
# DjrillMessage deprecation is tested in test_deprecated_djrill_message_class above
|
||||||
|
warnings.filterwarnings('ignore', category=RemovedInDjrill2,
|
||||||
|
message="DjrillMessage will be removed in Djrill 2.0")
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.subject = "Djrill baby djrill."
|
self.subject = "Djrill baby djrill."
|
||||||
self.from_name = "Tarzan"
|
self.from_name = "Tarzan"
|
||||||
|
|||||||
@@ -47,6 +47,14 @@ in debug mode.)
|
|||||||
or `datetime` values used in any Mandrill message attributes other
|
or `datetime` values used in any Mandrill message attributes other
|
||||||
than `send_at`. See :ref:`formatting-merge-data` for other options.
|
than `send_at`. See :ref:`formatting-merge-data` for other options.
|
||||||
|
|
||||||
|
* **DjrillMessage class**
|
||||||
|
|
||||||
|
The ``DjrillMessage`` class has not been needed since Djrill 0.2.
|
||||||
|
You can simply set Djrill message attributes on any Django
|
||||||
|
:class:`~django.core.mail.EmailMultiAlternatives` object.
|
||||||
|
Djrill 1.4 will report a `DeprecationWarning` if you are still
|
||||||
|
using ``DjrillMessage``.
|
||||||
|
|
||||||
|
|
||||||
Change Log
|
Change Log
|
||||||
----------
|
----------
|
||||||
|
|||||||
Reference in New Issue
Block a user