From 209f9573ff22a553ec996f1f2f0c76d3b7533cf7 Mon Sep 17 00:00:00 2001 From: medmunds Date: Sun, 29 Nov 2015 12:37:00 -0800 Subject: [PATCH] Drop legacy DjrillMessage class --- djrill/mail/__init__.py | 54 ------------------------ djrill/tests/test_legacy.py | 82 ------------------------------------- docs/history.rst | 14 +++---- 3 files changed, 5 insertions(+), 145 deletions(-) diff --git a/djrill/mail/__init__.py b/djrill/mail/__init__.py index 80a5504..e69de29 100644 --- a/djrill/mail/__init__.py +++ b/djrill/mail/__init__.py @@ -1,54 +0,0 @@ -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 -# compatibility with existing code. (New code can just set Mandrill-specific -# options directly on an EmailMessage or EmailMultiAlternatives object.) -class DjrillMessage(EmailMultiAlternatives): - alternative_subtype = "mandrill" - - def __init__(self, subject='', body='', from_email=None, to=None, bcc=None, - connection=None, attachments=None, headers=None, alternatives=None, - cc=None, from_name=None, tags=None, track_opens=True, - 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, - connection, attachments, headers, alternatives, cc) - - if from_name: - self.from_name = from_name - if tags: - self.tags = self._set_mandrill_tags(tags) - if track_opens is not None: - self.track_opens = track_opens - if track_clicks is not None: - self.track_clicks = track_clicks - if preserve_recipients is not None: - self.preserve_recipients = preserve_recipients - - def _set_mandrill_tags(self, tags): - """ - Check that all tags are below 50 chars and that they do not start - with an underscore. - - Raise ValueError if an underscore tag is passed in to - alert the user. Any tag over 50 chars is left out of the list. - """ - tag_list = [] - - for tag in tags: - if len(tag) <= 50 and not tag.startswith("_"): - tag_list.append(tag) - elif tag.startswith("_"): - raise ValueError( - "Tags starting with an underscore are reserved for " - "internal use and will cause errors with Mandrill's API") - - return tag_list diff --git a/djrill/tests/test_legacy.py b/djrill/tests/test_legacy.py index 3213508..b0d5cc3 100644 --- a/djrill/tests/test_legacy.py +++ b/djrill/tests/test_legacy.py @@ -8,7 +8,6 @@ from django.test import TestCase from djrill import MandrillAPIError, NotSupportedByMandrillError from djrill.exceptions import RemovedInDjrill2 -from djrill.mail import DjrillMessage from djrill.tests.mock_backend import DjrillBackendMockAPITestCase from djrill.tests.utils import reset_warning_registry @@ -37,12 +36,6 @@ class DjrillBackendDeprecationTests(DjrillBackendMockAPITestCase): self.assertEqual(data['message']['global_merge_vars'], [{'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 test_deprecated_djrill_backend_http_error(self): """Djrill 0.2 deprecated DjrillBackendHTTPError; 2.0 will drop it""" def try_import(): @@ -72,81 +65,6 @@ class DjrillBackendDeprecationTests(DjrillBackendMockAPITestCase): msg="Unexpected warnings %r" % [str(w) for w in relevant_warnings]) -class DjrillMessageTests(TestCase): - """Test the DjrillMessage class (deprecated as of Djrill v0.2.0) - - Maintained for compatibility with older code. - - """ - - 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): - self.subject = "Djrill baby djrill." - self.from_name = "Tarzan" - self.from_email = "test@example" - self.to = ["King Kong ", - "Cheetah