dimanche 22 juillet 2018

How to test url when primary key variable is in the middle

I use TestCase to test my django project. And when I want to test the URL for a book's detail I will visit the URL

/books/<int:pk>/

I will test the url in my test file by

self.client.get('/books/', kwargs={'pk':self.book.pk})

The PROBLEM is: If the url of book details lies at

/books/mathbranch/<int:pk>/books/

How can I write a test for this url?

Thank you!

Aucun commentaire:

Enregistrer un commentaire