mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Drop legacy DjrillBackendHTTPError exception
This commit is contained in:
@@ -409,26 +409,3 @@ class DjrillBackend(BaseEmailBackend):
|
|||||||
'content': content_b64.decode('ascii'),
|
'content': content_b64.decode('ascii'),
|
||||||
}
|
}
|
||||||
return mandrill_attachment, is_embedded_image
|
return mandrill_attachment, is_embedded_image
|
||||||
|
|
||||||
|
|
||||||
############################################################################################
|
|
||||||
# Recreate this module, but with a warning on attempts to import deprecated properties.
|
|
||||||
# This is ugly, but (surprisingly) blessed: http://stackoverflow.com/a/7668273/647002
|
|
||||||
import sys
|
|
||||||
import types
|
|
||||||
|
|
||||||
|
|
||||||
class ModuleWithDeprecatedProps(types.ModuleType):
|
|
||||||
def __init__(self, module):
|
|
||||||
self._orig_module = module # must keep a ref around, or it'll get deallocated
|
|
||||||
super(ModuleWithDeprecatedProps, self).__init__(module.__name__, module.__doc__)
|
|
||||||
self.__dict__.update(module.__dict__)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def DjrillBackendHTTPError(self):
|
|
||||||
removed_in_djrill_2("DjrillBackendHTTPError will be removed in Djrill 2.0. "
|
|
||||||
"Use djrill.MandrillAPIError instead.")
|
|
||||||
return MandrillAPIError
|
|
||||||
|
|
||||||
|
|
||||||
sys.modules[__name__] = ModuleWithDeprecatedProps(sys.modules[__name__])
|
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import warnings
|
|||||||
from django.core import mail
|
from django.core import mail
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from djrill import MandrillAPIError, NotSupportedByMandrillError
|
from djrill import NotSupportedByMandrillError
|
||||||
from djrill.exceptions import RemovedInDjrill2
|
|
||||||
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
|
||||||
|
|
||||||
@@ -36,15 +35,6 @@ 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_backend_http_error(self):
|
|
||||||
"""Djrill 0.2 deprecated DjrillBackendHTTPError; 2.0 will drop it"""
|
|
||||||
def try_import():
|
|
||||||
# noinspection PyUnresolvedReferences
|
|
||||||
from djrill.mail.backends.djrill import DjrillBackendHTTPError
|
|
||||||
self.assertWarnsMessage(DeprecationWarning,
|
|
||||||
"DjrillBackendHTTPError will be removed in Djrill 2.0",
|
|
||||||
try_import)
|
|
||||||
|
|
||||||
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:
|
||||||
@@ -66,17 +56,6 @@ class DjrillBackendDeprecationTests(DjrillBackendMockAPITestCase):
|
|||||||
|
|
||||||
|
|
||||||
class DjrillLegacyExceptionTests(TestCase):
|
class DjrillLegacyExceptionTests(TestCase):
|
||||||
def test_DjrillBackendHTTPError(self):
|
|
||||||
"""MandrillApiError was DjrillBackendHTTPError in 0.2.0"""
|
|
||||||
# ... and had to be imported from deep in the package:
|
|
||||||
with warnings.catch_warnings():
|
|
||||||
warnings.filterwarnings('ignore', category=RemovedInDjrill2,
|
|
||||||
message="DjrillBackendHTTPError will be removed in Djrill 2.0")
|
|
||||||
# noinspection PyUnresolvedReferences
|
|
||||||
from djrill.mail.backends.djrill import DjrillBackendHTTPError
|
|
||||||
ex = MandrillAPIError("testing")
|
|
||||||
self.assertIsInstance(ex, DjrillBackendHTTPError)
|
|
||||||
|
|
||||||
def test_NotSupportedByMandrillError(self):
|
def test_NotSupportedByMandrillError(self):
|
||||||
"""Unsupported features used to just raise ValueError in 0.2.0"""
|
"""Unsupported features used to just raise ValueError in 0.2.0"""
|
||||||
ex = NotSupportedByMandrillError("testing")
|
ex = NotSupportedByMandrillError("testing")
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ Removed DjrillMessage class
|
|||||||
You should replace any uses of it with the standard
|
You should replace any uses of it with the standard
|
||||||
:class:`~django.core.mail.EmailMessage` class.
|
:class:`~django.core.mail.EmailMessage` class.
|
||||||
|
|
||||||
|
Removed DjrillBackendHTTPError
|
||||||
|
This exception was deprecated in Djrill 0.3. Replace uses of it
|
||||||
|
with :exc:`djrill.MandrillAPIError`.
|
||||||
|
|
||||||
|
|
||||||
**Dates in merge data and other attributes**
|
**Dates in merge data and other attributes**
|
||||||
|
|
||||||
@@ -72,13 +76,6 @@ 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.
|
||||||
|
|
||||||
|
|
||||||
**DjrillBackendHTTPError**
|
|
||||||
|
|
||||||
The ``DjrillBackendHTTPError`` exception was replaced in Djrill 0.3
|
|
||||||
with :exc:`djrill.MandrillAPIError`. Djrill 1.4 will report a
|
|
||||||
DeprecationWarning if you are still importing DjrillBackendHTTPError.
|
|
||||||
|
|
||||||
|
|
||||||
Older Releases
|
Older Releases
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user