summaryrefslogtreecommitdiff
path: root/tests/regressiontests/admin_validation/tests.py
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2011-02-26 02:00:18 +0000
committerRamiro Morales <cramm0@gmail.com>2011-02-26 02:00:18 +0000
commit049b3ff8a25a3907e7791091cb6a87910cff95df (patch)
tree5ec9da3390e3acdd460ef4a18699c9aec1360eea /tests/regressiontests/admin_validation/tests.py
parent9a5ebbcac9480c265e8f736ec3bceb2e8a3546b9 (diff)
[1.2.X] Fixed #15424 -- Corrected lookup of callables listed in admin inlines' `readonly_fields` by passing the right ModelAdmin (sub)class instance when instantiating inline forms admin wrappers. Also, added early validation of its elements. Thanks kmike for the report and Karen for the patch fixing the issue.
Backport of [15650] from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15651 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_validation/tests.py')
-rw-r--r--tests/regressiontests/admin_validation/tests.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/regressiontests/admin_validation/tests.py b/tests/regressiontests/admin_validation/tests.py
index 1872ca55e2..6fbdc8040e 100644
--- a/tests/regressiontests/admin_validation/tests.py
+++ b/tests/regressiontests/admin_validation/tests.py
@@ -4,7 +4,7 @@ from django.contrib.admin.validation import validate, validate_inline, \
ImproperlyConfigured
from django.test import TestCase
-from models import Song, Book, Album, TwoAlbumFKAndAnE
+from models import Song, Book, Album, TwoAlbumFKAndAnE, State, City
class SongForm(forms.ModelForm):
pass
@@ -162,6 +162,16 @@ class ValidationTestCase(TestCase):
validate,
SongAdmin, Song)
+ def test_nonexistant_field_on_inline(self):
+ class CityInline(admin.TabularInline):
+ model = City
+ readonly_fields=['i_dont_exist'] # Missing attribute
+
+ self.assertRaisesMessage(ImproperlyConfigured,
+ "CityInline.readonly_fields[0], 'i_dont_exist' is not a callable or an attribute of 'CityInline' or found in the model 'City'.",
+ validate_inline,
+ CityInline, None, State)
+
def test_extra(self):
class SongAdmin(admin.ModelAdmin):
def awesome_song(self, instance):
@@ -241,7 +251,3 @@ class ValidationTestCase(TestCase):
fields = ['title', 'extra_data']
validate(FieldsOnFormOnlyAdmin, Song)
-
-
-
-