From the course: Building React and Django Apps

Unlock the full course today

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

Unit testing validation for the REST API

Unit testing validation for the REST API

From the course: Building React and Django Apps

Start my 1-month free trial

Unit testing validation for the REST API

- [Instructor] Let's write a unit test to test the custom street address validation we added earlier. We have to set up the invalid form data first, then we confirm that submitting this invalid data will return the street address error message. We post to the bookings api endpoint with this invalid data and we make sure that the response code is a 400, and we also make sure that the error message matches the street address error message. And then, when we submit the correct data, we want to make sure that the booking model is created. So we post again to bookings with this valid data and then we assert that the status code is a 201. Now we run the tests.

Contents