Home / Companies / Twilio / Blog / Post Details
Content Deep Dive

Mock it Til’ You Make It: Test Django with mock and httpretty

Blog post from Twilio

Post Details
Company
Date Published
Author
Ersel Aker
Word Count
2,054
Language
English
Hacker News Points
-
Summary

The tutorial covers how to use Python's mock and httpretty libraries to test Django app parts that communicate with external services. It uses a simple Django app called "Hacker News Hotline" to fetch today's headlines from Hacker News and serve them behind a TwiML endpoint, allowing anyone calling the Twilio number to hear the latest headlines on Hacker News. The tutorial also introduces Django's RequestFactory class and how it can be used to test Django views without making actual HTTP requests.