Open mschoettle opened 2 years ago
@mschoettle Thanks for raising this, but I don't see any inconsistency.
You could spend all day testing Django, but what you're interested in is that your new code works, and that any changes you made to old code didn't have unexpected side effects.
The statement suggests that you should test your own code but that you shouldn't need to explicitly test Django's.
max_length
actually "works" (that's incidental)If the example does not test some parts of the design that it should I would be very happy to take a PR that notes the omission and suggests perhaps the reader fix as a test of their knowledge.
The book "Two Scoops of Django" recommends the following for what should be tested in models (Section 24.3.6, page 302): "Models: Creating/updating/deleting of models, model methods, model manager methods."
P.S. ^^^ Without reading that book I can't judge their logic. As above though, it makes sense if they are recommending you test your design "did I implement the model properly so it can be created", and little sense sense if they are suggesting you validate that Django can create/update models.
MDN URL: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Testing
What information was incorrect, unhelpful, or incomplete?
The section "What should you test?" advocates to test for the model's verbose name, max length etc.
This is the only resource where I could find such a suggestion. Most resources recommend to test any custom logic/functions (like
__str__
,get_absolute_url
etc.) which is also recommended in this tutorial after above quoted text.To me, other things like
blank=True
ornull=True
are also design decisions but they are not tested in this example. In addition, for example, callingCharField(max_length=100)
and then testing that the field'smax_length
is indeed100
is testing Django functionality.Specific section or headline?
Section "What should you test?"
What did you expect to see?
Honestly, I am not entirely sure but want to raise this (in my opinion) inconsistency and hopefully start a discussion.
The book "Two Scoops of Django" recommends the following for what should be tested in models (Section 24.3.6, page 302): "Models: Creating/updating/deleting of models, model methods, model manager methods."
Did you test this? If so, how?
n/a
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/main/files/en-us/learn/server-side/django/testing/index.md * Last commit: https://github.com/mdn/content/commit/c4b6112d856dbb5fa7b929e5034499c605a51e08 * Document last modified: 2022-03-28T14:52:22.000Z