mardi 2 janvier 2018

django test urls status code

hello i create some test for my project mainly to enrich my knowledge.

and I have some questions.

simple test code :

test.py

from django.test import Client, TestCase
class User_Form_Test(TestCase):
    def test_logged_user_get_dataset(self):
        response = self.client.get('/details/', follow=True)
        self.assertEqual(response.status_code, 200)

    def test_logged_user_get_disasters_projects(self):
        response = self.client.get('/details-images/', follow=True)
        self.assertEqual(response.status_code, 200)

urls.py

url(r'^details/(?P<id>\d+)/$', views.details, name='details'),
url(r'^details-images/(?P<slug>[^\.]+)/$', views.details_images, name='details_images')

all this code work fine I take passed messages in this two test.

my question is how to can test like this example all possible regex from id in first case and second slug in second case automate ?

Aucun commentaire:

Enregistrer un commentaire