summaryrefslogtreecommitdiff
path: root/tests/admin_checks/tests.py
diff options
context:
space:
mode:
authorMuthiah Annamalai <ezhillang@gmail.com>2015-01-10 11:45:05 -0500
committerTim Graham <timograham@gmail.com>2015-01-12 13:47:58 -0500
commitb75c707943e159b80c179c538721406bbfb8b120 (patch)
treea0c4a5bef239c2fd1a3df4c814383ffef9687c92 /tests/admin_checks/tests.py
parenteeb88123e725946802732162a22e5ad856e0c50c (diff)
Fixed #24089 -- Added check for when ModelAdmin.fieldsets[1]['fields'] isn't a list/tuple.
Diffstat (limited to 'tests/admin_checks/tests.py')
-rw-r--r--tests/admin_checks/tests.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py
index d8e6c125dd..ea0151cced 100644
--- a/tests/admin_checks/tests.py
+++ b/tests/admin_checks/tests.py
@@ -124,6 +124,55 @@ class SystemChecksTestCase(TestCase):
errors = ValidFormFieldsets.check(model=Song)
self.assertEqual(errors, [])
+ def test_fieldsets_fields_non_tuple(self):
+ """
+ Tests for a tuple/list within fieldsets[1]['fields'].
+ """
+ class NotATupleAdmin(admin.ModelAdmin):
+ list_display = ["pk", "title"]
+ list_editable = ["title"]
+ fieldsets = [
+ (None, {
+ "fields": "title" # not a tuple
+ }),
+ ]
+
+ errors = NotATupleAdmin.check(model=Song)
+ expected = [
+ checks.Error(
+ "The value of 'fieldsets[1]['fields']' must be a list or tuple.",
+ hint=None,
+ obj=NotATupleAdmin,
+ id='admin.E008',
+ )
+ ]
+ self.assertEqual(errors, expected)
+
+ def test_nonfirst_fieldset(self):
+ """
+ Tests for a tuple/list within the second fieldsets[2]['fields'].
+ """
+ class NotATupleAdmin(admin.ModelAdmin):
+ fieldsets = [
+ (None, {
+ "fields": ("title",)
+ }),
+ ('foo', {
+ "fields": "author" # not a tuple
+ }),
+ ]
+
+ errors = NotATupleAdmin.check(model=Song)
+ expected = [
+ checks.Error(
+ "The value of 'fieldsets[1]['fields']' must be a list or tuple.",
+ hint=None,
+ obj=NotATupleAdmin,
+ id='admin.E008',
+ )
+ ]
+ self.assertEqual(errors, expected)
+
def test_exclude_values(self):
"""
Tests for basic system checks of 'exclude' option values (#12689)