1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

[1.7x.] Fixed #23497 -- Made admin system checks run for custom AdminSites.

Backport of b7219c7ba5 from master
This commit is contained in:
Mosson, Andrew
2014-12-14 05:22:37 +02:00
committed by Tim Graham
parent a38951948a
commit 6d8c14621e
4 changed files with 31 additions and 12 deletions

View File

@@ -7,7 +7,7 @@ from django.contrib import admin
from django.contrib.contenttypes.admin import GenericStackedInline
from django.core import checks
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
from django.test import override_settings, TestCase
from .models import Song, Book, Album, TwoAlbumFKAndAnE, City, State, Influence
@@ -34,14 +34,16 @@ class ValidFormFieldsets(admin.ModelAdmin):
)
class MyAdmin(admin.ModelAdmin):
@classmethod
def check(cls, model, **kwargs):
return ['error!']
class SystemChecksTestCase(TestCase):
@override_settings(DEBUG=True)
def test_checks_are_performed(self):
class MyAdmin(admin.ModelAdmin):
@classmethod
def check(self, model, **kwargs):
return ['error!']
admin.site.register(Song, MyAdmin)
try:
errors = checks.run_checks()
@@ -49,6 +51,22 @@ class SystemChecksTestCase(TestCase):
self.assertEqual(errors, expected)
finally:
admin.site.unregister(Song)
admin.sites.system_check_errors = []
@override_settings(DEBUG=True)
def test_custom_adminsite(self):
class CustomAdminSite(admin.AdminSite):
pass
custom_site = CustomAdminSite()
custom_site.register(Song, MyAdmin)
try:
errors = checks.run_checks()
expected = ['error!']
self.assertEqual(errors, expected)
finally:
custom_site.unregister(Song)
admin.sites.system_check_errors = []
def test_readonly_and_editable(self):
class SongAdmin(admin.ModelAdmin):