mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-21 12:21:06 -05:00
Deprecate DjrillAdminSite
This commit is contained in:
@@ -6,14 +6,9 @@ from django.contrib.auth.models import User
|
||||
from django.contrib import admin
|
||||
import six
|
||||
|
||||
from djrill.exceptions import RemovedInDjrill2
|
||||
from djrill.tests.mock_backend import DjrillBackendMockAPITestCase
|
||||
|
||||
from .utils import override_settings
|
||||
|
||||
# We don't care that the `cycle` template tag will be removed in Django 2.0,
|
||||
# because we're planning to drop the Djrill admin templates before then.
|
||||
warnings.filterwarnings('ignore', category=PendingDeprecationWarning,
|
||||
message="Loading the `cycle` tag from the `future` library")
|
||||
from djrill.tests.utils import override_settings
|
||||
|
||||
|
||||
def reset_admin_site():
|
||||
@@ -34,6 +29,21 @@ class DjrillAdminTests(DjrillBackendMockAPITestCase):
|
||||
# so return it to the default state before loading test_admin_urls
|
||||
reset_admin_site()
|
||||
|
||||
def run(self, result=None):
|
||||
with warnings.catch_warnings():
|
||||
# DjrillAdminSite deprecation is tested in test_legacy
|
||||
warnings.filterwarnings('ignore', category=RemovedInDjrill2,
|
||||
message="DjrillAdminSite will be removed in Djrill 2.0")
|
||||
# We don't care that the `cycle` template tag will be removed in Django 2.0,
|
||||
# because we're planning to drop the Djrill admin templates before then.
|
||||
warnings.filterwarnings('ignore', category=PendingDeprecationWarning,
|
||||
message="Loading the `cycle` tag from the `future` library")
|
||||
# We don't care that user messaging was deprecated in Django 1.3
|
||||
# (testing artifact of our runtests.py minimal Django settings)
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning,
|
||||
message="The user messaging API is deprecated.")
|
||||
super(DjrillAdminTests, self).run(result)
|
||||
|
||||
def setUp(self):
|
||||
super(DjrillAdminTests, self).setUp()
|
||||
# Must be authenticated staff to access admin site...
|
||||
|
||||
@@ -6,14 +6,24 @@ import warnings
|
||||
from django.core import mail
|
||||
from django.test import TestCase
|
||||
|
||||
from djrill import MandrillAPIError, NotSupportedByMandrillError, DjrillAdminSite
|
||||
from djrill.mail import DjrillMessage
|
||||
from djrill import MandrillAPIError, NotSupportedByMandrillError
|
||||
|
||||
from .mock_backend import DjrillBackendMockAPITestCase
|
||||
from djrill.tests.mock_backend import DjrillBackendMockAPITestCase
|
||||
from djrill.tests.utils import reset_warning_registry
|
||||
|
||||
|
||||
class DjrillBackendDeprecationTests(DjrillBackendMockAPITestCase):
|
||||
|
||||
def setUp(self):
|
||||
reset_warning_registry()
|
||||
super(DjrillBackendDeprecationTests, self).setUp()
|
||||
|
||||
def test_deprecated_admin_site(self):
|
||||
"""Djrill 2.0 drops the custom DjrillAdminSite"""
|
||||
self.assertWarnsMessage(DeprecationWarning,
|
||||
"DjrillAdminSite will be removed in Djrill 2.0",
|
||||
DjrillAdminSite)
|
||||
|
||||
def test_deprecated_json_date_encoding(self):
|
||||
"""Djrill 2.0+ avoids a blanket JSONDateUTCEncoder"""
|
||||
# Djrill allows dates for send_at, so shouldn't warn:
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import re
|
||||
import six
|
||||
import sys
|
||||
|
||||
__all__ = (
|
||||
'BackportedAssertions',
|
||||
'override_settings',
|
||||
'reset_warning_registry',
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -86,3 +88,18 @@ class BackportedAssertions(object):
|
||||
callable_obj=None, *args, **kwargs):
|
||||
return six.assertRaisesRegex(self, expected_exception, re.escape(expected_message),
|
||||
callable_obj, *args, **kwargs)
|
||||
|
||||
|
||||
# Backport from Django 1.8 (django.test.utils)
|
||||
def reset_warning_registry():
|
||||
"""
|
||||
Clear warning registry for all modules. This is required in some tests
|
||||
because of a bug in Python that prevents warnings.simplefilter("always")
|
||||
from always making warnings appear: http://bugs.python.org/issue4180
|
||||
|
||||
The bug was fixed in Python 3.4.2.
|
||||
"""
|
||||
key = "__warningregistry__"
|
||||
for mod in sys.modules.values():
|
||||
if hasattr(mod, key):
|
||||
getattr(mod, key).clear()
|
||||
|
||||
Reference in New Issue
Block a user