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
From the course: Building React and Django Apps
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.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
Unit testing a component1m 44s
-
Unit testing two React routes and navigation between components2m 15s
-
End2End testing the form submission process1m 30s
-
End2End testing the filtered data table48s
-
Unit testing caching with Django REST framework50s
-
Unit testing sorting and filtering1m 37s
-
Unit testing validation for the REST API59s
-
-