2nd edition. — O’Reilly Media. — 592 p. — ISBN13: 978-1491958704.
By taking you through the development of a real web application from beginning to end, the updated second edition of this hands-on guide demonstrates the practical advantages of test-driven development (TDD) with Python. You’ll learn how to write and run tests before building each part of your app, and then develop the minimum amount of code required to pass those tests. The result? Clean code that works.
Author Harry J.W. Percival uses a concrete example — the development of a web site, from scratch — to teach TDD methodology and how it applies to web programming, from the basics of database integration and JavaScript to more advanced topics such as mocking, Ajax, and REST APIs. It's ideal for relative newcomers and self-taught web developers looking to take their skills to the next level with a more structured approach.
Getting Django Set Up Using a Functional Test
Extending the Functional Test Using the Unittest Module
Testing a Simple Home Page with Unit Tests
What Are We Doing with All These Tests
Saving User Input: Testing the Database
Improving Functional Tests: Ensuring Isolation and Removing Voodoo Sleeps
Working Incrementally
Prettication: Layout and Styling, and What to Test About It
Testing Deployment Using a Staging Site
Getting to a Production-Ready Deployment
Automating Deployment with Fabric
Splitting our tests into multiple €les, and a generic wait helper
Validation at the Database Layer
A Simple Form
More Advanced Forms
Dipping Our Toes, Very Tentatively, into JavaScript
Deploying Our New Code
User Authentication, Spiking and De-Spiking-In TDD
Using Mocks to Test External Dependencies or Reduce Duplication
Test Fixtures and a Decorator for Explicit Waits
Server-Side Debugging
Finishing “My Lists”: Outside-In TDD
Test Isolation, and “Listening to Your Tests"
Continuous Integration (CI)
The Token Social Bit, the Page Pattern, and an Exercise for the Reader
Fast Tests, Slow Tests, and Hot Lava
Python Anywhere
Django Class-Based Views
Provisioning with Ansible
Testing Database Migrations
Behavior Driven Development
Building a REST API: JSON, Ajax, and Mocking with JavaScript
Django-Rest-Framework
Cheat Sheet
What to Do Next