Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - testing pages for 500 status

I've got a project where some changes may lead to 500 status in some views.

What is the most elegant way to make unit tests that will check all the views/pages (with static routes, without vars in them, of course) for not returning 500 status?

like image 870
DataGreed Avatar asked Nov 03 '22 09:11

DataGreed


1 Answers

For unit tests you can use something like:

from django import test
from django.core.urlresolvers import reverse
from page.urls import urlpatterns

class PageTest(test.TestCase):

   def test_responses(self):
       for url in urlpatterns:
           response = self.client.get(reverse(url.name))
           self.assertEqual(response.status_code, 200)
like image 88
sneawo Avatar answered Nov 12 '22 11:11

sneawo