From 0fa6ab8c181879fdce4a122691be88e897ba564d Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 23 Feb 2018 13:12:09 -0500 Subject: [PATCH] Tested the admin's delete_selected action when it receives nonexistent pks. --- tests/admin_views/test_actions.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/admin_views/test_actions.py b/tests/admin_views/test_actions.py index b77714b32d..4823316e3e 100644 --- a/tests/admin_views/test_actions.py +++ b/tests/admin_views/test_actions.py @@ -61,6 +61,17 @@ class AdminActionsTest(TestCase): self.client.post(reverse('admin:admin_views_subscriber_changelist'), delete_confirmation_data) self.assertEqual(Subscriber.objects.count(), 0) + def test_default_delete_action_nonexistent_pk(self): + self.assertFalse(Subscriber.objects.filter(id=9998).exists()) + action_data = { + ACTION_CHECKBOX_NAME: ['9998'], + 'action': 'delete_selected', + 'index': 0, + } + response = self.client.post(reverse('admin:admin_views_subscriber_changelist'), action_data) + self.assertContains(response, 'Are you sure you want to delete the selected subscribers?') + self.assertContains(response, '', html=True) + @override_settings(USE_THOUSAND_SEPARATOR=True, USE_L10N=True) def test_non_localized_pk(self): """