From the course: Securing Django Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Unit test for per-object permissions in Django

Unit test for per-object permissions in Django - Django Tutorial

From the course: Securing Django Applications

Start my 1-month free trial

Unit test for per-object permissions in Django

- [Instructor] Let's unit test the per object permission testing. We already have the setup for the test. It shows that there's a package already existing, and two users have been created. In our test, we're going to try updating a booking, made by one user and updating it from a second user. So we're to create the booking. (keyboard stroking) The email address will be the email address of the first user. (keyboard stroking) And then we're going to save the booking. (keyboard stroking) And we're going to assert that our post save signal is working correctly, by asserting that the first user has permission to change the booking. (keyboard stroking) Then we're going to make sure that the second user, (keyboard stroking) does not have permission to change that booking. (keyboard stroking) Then we're going to be making an API call. (keyboard stroking) And we're going to be updating the name of that booking.…

Contents