Tested the admin's delete_selected action when it receives nonexistent pks.

This commit is contained in:
Tim Graham 2018-02-23 13:12:09 -05:00
parent ba37ee9ef8
commit 0fa6ab8c18
1 changed files with 11 additions and 0 deletions

View File

@ -61,6 +61,17 @@ class AdminActionsTest(TestCase):
self.client.post(reverse('admin:admin_views_subscriber_changelist'), delete_confirmation_data) self.client.post(reverse('admin:admin_views_subscriber_changelist'), delete_confirmation_data)
self.assertEqual(Subscriber.objects.count(), 0) 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, '<ul></ul>', html=True)
@override_settings(USE_THOUSAND_SEPARATOR=True, USE_L10N=True) @override_settings(USE_THOUSAND_SEPARATOR=True, USE_L10N=True)
def test_non_localized_pk(self): def test_non_localized_pk(self):
""" """