From 70d0a1ca02f42c0f8984b6234ca0f9d7e354a135 Mon Sep 17 00:00:00 2001 From: Przemysław Buczkowski Date: Thu, 13 Sep 2018 13:36:14 +0100 Subject: Fixed #29711 -- Added a system check for uniquness of admin actions' __name__. --- tests/modeladmin/test_checks.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/modeladmin/test_checks.py') diff --git a/tests/modeladmin/test_checks.py b/tests/modeladmin/test_checks.py index 6a10441471..89fde35d3c 100644 --- a/tests/modeladmin/test_checks.py +++ b/tests/modeladmin/test_checks.py @@ -1309,3 +1309,30 @@ class ActionsCheckTests(CheckTestCase): 'custom_permission_action action.', id='admin.E129', ) + + def test_actions_not_unique(self): + def action(modeladmin, request, queryset): + pass + + class BandAdmin(ModelAdmin): + actions = (action, action) + + self.assertIsInvalid( + BandAdmin, Band, + "__name__ attributes of actions defined in " + ".BandAdmin'> must be unique.", + id='admin.E130', + ) + + def test_actions_unique(self): + def action1(modeladmin, request, queryset): + pass + + def action2(modeladmin, request, queryset): + pass + + class BandAdmin(ModelAdmin): + actions = (action1, action2) + + self.assertIsValid(BandAdmin, Band) -- cgit v1.3