In this video, you learn to create a unit test for deleting (or destroying) models from the database through the REST API. Explore the assurances needed to confirm the data is deleted through the DestroyAPIView.
- [Narrator] We tested creating products through the API, … so let's test destroying and deleting products … through the API. … We write a new test case … (typing) … for ProductDestroy. … (typing) … We're going to be checking the product count... … (typing) … and making sure that the product doesn't exist anymore … (typing) … after we delete it. … So we use the client, called the delete method, on it, … (typing) … and then we make sure that there's one less object … in the database. … (typing) … And we also make sure that if we try … and retrieve that particular product, … it no longer exists. … (typing) … In the real world, we would also check to ensure … that caches or any other data related to the product model … are also destroyed and cleaned up. … So now let's run the test. … (typing) … It looks like all test paths and products can be deleted. … …
- Creating a serializer
- Working with API views
- Filtering back ends
- Enabling pagination
- Executing CRUD operations
- Managing serializer fields
- Testing API views
Skill Level Intermediate
Deploying Django Apps: Make Your Site Go Livewith Nick Walter2h 43m Intermediate
Demo project overview1m 19s
1. Serializing, Listing, Filtering, and Paginating Models
2. Create, Retrieve, Update, and Delete (CRUD) Operations for Models
3. Managing Serializer Fields, Relations, and Validation
4. Testing API Views
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.