In this video, learn how to write a test case for the ImageField serializer field to ensure users can upload images correctly.
- [Man] We're able to update the product, … so let's test updating a product … with a new product image upload. … We begin by importing OS.Path, … since we are dealing with files and images. … And we're going to import Django settings. … And then we go to the product update Test Case, … and we add a New Test Case to it, … for Upload Product Photo. … We're going to use the first product in the database. … We're going to store the original photo. … And then we're going to create the Path … to the new photo, … and just re-use … an existing product photo from our Media Root. … And then, with that photo, Path open, … going to to store that photo data, … and use it … to update the product photo. … And the format is not Json, but it is Multipart … because it is an upload. … And immediately after that, we're going to be checking … to ensure that the Response Status Code … was a 200 and okay. … After that, we want to make sure … that the photo from the response … is no longer the original photo. …
- 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.