Skip to content
Advertisement

how do I efficiently test this Django model?

I’m building an authentication system for a website, I don’t have prior test experience with Django. I have written some basic tests.

the model,

JavaScript

and model manager,

JavaScript

and my tests,

JavaScript

fortunately all the passes, and my question is, are these tests overdone or underdone or normal? What should be tested in a model? is there any procedure missing? anything wrong with this tests?? how do I effectively write tests??

thank you for any insights.

Advertisement

Answer

That’s quite enough. Just a couple of notes:

  1. No need to delete properties in tearDown
  2. You forgot to tests UserManager in lines raise ValueError using assertRaises.
  3. You may also test that user created by create_user(from UserManager) can authenticate(from django.contrib.auth) by given password and email.
  4. Use coverage package to detect which lines/classes/packages/statements were missed to test.
Advertisement