Open ifrh opened 3 years ago
@ifrh Thanks for posting this. Yes, that could be interesting as it isn't documented properly anywhere - including in Django docs. Some resources from around the place to help with this:
Would you like to take it on? (I might look at this, but not necessarily any time soon!)
@ifrh Thanks for posting this. Yes, that could be interesting as it isn't documented properly anywhere - including in Django docs. Some resources from around the place to help with this:
@hamishwillee Thanks for your pointers :)
* A video: https://youtu.be/S1hPHP9wBhw * Checkout what Django did in their tests: https://github.com/django/django/blob/master/tests/modeladmin/tests.py * This might be useful too: https://stackoverflow.com/a/54667823/894359 "testing admin.ModelAdmin in django"
Would you like to take it on? (I might look at this, but not necessarily any time soon!)
Just now I found https://stackoverflow.com/a/54799934 and https://stackoverflow.com/a/29027215 which are answers to "Testing custom admin actions in django".
There (https://stackoverflow.com/a/29027215) it is written:
change_url = urlresolvers.reverse('admin:app_model_changelist')
Just pass the parameter action
with the action name.
response = client.post(change_url, {'action': 'mark_as_read', ...})
And https://stackoverflow.com/a/54799934 gives a more or less complete example. But for learning in contrast to copy and modify there are to few things that are explained.
MDN URL: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Testing
A great overview of testing with python django ! Thank you very much.
What information was incorrect, unhelpful, or incomplete?
No example is given for writing a unit test which should test a "action" from admin site list views.
Proposed section or headline
Testing actions from admin site list views
What did you expect to see?
It would be very great, if there is a small example how to write a unit test for actions on admin site list views.
MDN Content page report details
* Folder: `en-us/learn/server-side/django/testing` * MDN URL: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Testing * GitHub URL: https://github.com/mdn/content/blob/master/files/en-us/learn/server-side/django/testing/index.html * Last commit: https://github.com/mdn/content/commit/edbcbfa37c7807eefc5346c734cfc55d3dcc2c8a * Document last modified: 2021-01-25T07:12:53.000Z