Learn to unit test date and time fields and ensure a product’s price changes only during a sales event week, by create a test case for updating a model that uses date/time fields.
- [Narrator] Now let's test updating a product. … We write another API test case. … And this one is going to be using … the PATCH method for partially updating the model. … Going to grab the first product, … and then, we call PATCH from the client, … pointing to that specific product's API URL. … We're going to be updating the name to new product, … updating the description, … and then updating the price. … Format of the request is JSON, … and then we retrieve the updated product … from the database, and we're going to make sure … that the name has actually updated. … Now let's run the test and see what happens. … It looks like the product's data doesn't update. … So let's try and fix this. … Let's go to the serializers, … and it looks like an issue with the product serializer, … and in the UPDI method, it looks like … we update the data with the warranty information, … but then we actually forget to call the super method, … so that the product is updated correctly. … So let's do that now. …
- 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.