mercredi 29 août 2018

Difference between test_urls.py and test_views.py

I'm currently learning how to write tests in Django: I've used the approach to create an extra test folder which has test files for every "Django module".

tests/
    test_urls.py
    test_views.py
    test_models.py
    ...

My problem is that I don't know the exact different between the test_urls.py file and test_views.py

For example I have this test:

def test_login_url(self):
    path = reverse('login')
    response = self.client.get(path)
    self.assertEqual(response.status_code, 200)

Should I place this test in the test_urls.py file or in test_views.py The "login" url is in the urls.py file but the view that belongs to that url is in views.py

Which file should I choose? Are there any best practices for this?

Aucun commentaire:

Enregistrer un commentaire