Now that you've implemented a method to counteract a flood of requests, you need to check it. In this video, learn how to write a unit test to ensure that certain Django REST API actions are happening only once.
- [Instructor] Let's open the test file … and write a test case for the cooldown throttling period. … We already have the Django cache imported, … and we have our package create view test case … with some sample data. … So before we start testing, … we need to setup what are the expectations here, … which is that after we make a request, we're going to be seeing … that one additional object was created. … So before the request, … we want to make sure that the cache key package created … has not been set. … Now, we're going to make our first request, … which is to create a new package, … going to use that sample data. … And we're going to make sure that … right after this first request, the cache key has been set, … and then we're going to make sure that the response … was also 201 to indicate that the object was created. … And then we're going to make sure that the number of objects … in the database has actually been updated. … Now in our second request, … we're going to use the same sample data, …
Skill Level Advanced
Building a Paid Membership Site with Djangowith Nick Walter1h 15m Intermediate
OWASP Top 10: #7 XSS and #8 Insecure Deserializationwith Caroline Wong26m 31s Intermediate
Building RESTful Web APIs with Djangowith Rudolf Olah1h 9m Intermediate
1. Permissions, Access Controls, Activity Logs
2. Throttling a Flood of Requests
3. Protecting Data and Data Privacy
4. 2FA: Two-Factor Authentication
5. CSRF: Cross-Site Request Forgery Protection
- 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.