--
Ticket URL: <https://code.djangoproject.com/ticket/29885>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> after upgrading from 2.0.9 to 2.1.2 we have a problem with a test like
> this:
> {{{
> @patch.object(SomeModelAdmin, 'action_to_mock')
> def test_admin_action_is_triggered(self, action_mock):
> url = reverse('admin:some_model_changelist')
> data = {'action': 'action_to_mock', '_selected_action': [1, 2]}
> self.client.post(url, data)
> self.assertTrue(action_mock.called)
> }}}
> on versions <2.1 it works fine. called is set to True and the call_count
> increases.
> I can't find anything in the changelogs so I assume it's a bug
New description:
after upgrading from 2.0.9 to 2.1.2 we have a problem with a test like
this:
{{{
#!python
@patch.object(SomeModelAdmin, 'action_to_mock')
def test_admin_action_is_triggered(self, action_mock):
url = reverse('admin:some_model_changelist')
data = {'action': 'action_to_mock', '_selected_action': [1, 2]}
self.client.post(url, data)
self.assertTrue(action_mock.called)
}}}
on versions <2.1 it works fine. called is set to True and the call_count
increases.
I can't find anything in the changelogs so I assume it's a bug
--
--
Ticket URL: <https://code.djangoproject.com/ticket/29885#comment:1>
* status: new => closed
* resolution: => invalid
Comment:
This was probably caused by #29419.
Which is mentioned in the release notes
https://docs.djangoproject.com/en/2.1/releases/2.1/#minor-features
https://docs.djangoproject.com/en/2.1/ref/contrib/admin/actions/#setting-
permissions-for-actions
Since you are mocking the function you must make sure it doesn't have an
`allowed_permissions` attribute
https://github.com/django/django/commit/958c7b301ead79974db8edd5b9c6588a10a28ae7
#diff-3c42de3e53aba87b32c494f995a728dfR878
A simple `delattr(action_mock, 'allowed_permissions')` before the
`self.client.post` should do.
--
Ticket URL: <https://code.djangoproject.com/ticket/29885#comment:2>