Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FeatureRequest with "Django Tutorial Part 10: Testing a Django web appl…": add a unit test for Admin-Site "action" #1915

Open
ifrh opened this issue Jan 31, 2021 · 2 comments
Labels
Content:Learn:Django Learning area Django docs

Comments

@ifrh
Copy link

ifrh commented Jan 31, 2021

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
@Ryuno-Ki Ryuno-Ki added the Content:Learn Learning area docs label Jan 31, 2021
@hamishwillee
Copy link
Collaborator

hamishwillee commented Feb 1, 2021

@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
Copy link
Author

ifrh commented Feb 1, 2021

@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.

@chrisdavidmills chrisdavidmills added the Content:Learn:Django Learning area Django docs label Feb 2, 2021
@hamishwillee hamishwillee removed the Content:Learn Learning area docs label Feb 3, 2021
MendyBerger pushed a commit to MendyBerger/content that referenced this issue Nov 30, 2021
classes-static: Show class static initialization block
@github-actions github-actions bot added the idle label Dec 8, 2021
@ddbeck ddbeck added Content:Learn Learning area docs and removed Content:Learn:Django Learning area Django docs labels Mar 31, 2022
@teoli2003 teoli2003 reopened this May 29, 2022
@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label May 29, 2022
@sideshowbarker sideshowbarker removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label May 30, 2022
@Josh-Cena Josh-Cena added Content:Learn:Django Learning area Django docs and removed Content:Learn Learning area docs community labels Jan 4, 2023
@Josh-Cena Josh-Cena changed the title FeatureRequest with "Django Tutorial Part 10: Testing a Django web appl…": (Please show a UnitTest for Admin-Site "action"-) FeatureRequest with "Django Tutorial Part 10: Testing a Django web appl…": add a unit test for Admin-Site "action" Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Learn:Django Learning area Django docs
Projects
None yet
Development

No branches or pull requests

9 participants