Obey the Testing Goat: Using Django, Selenium, and JavaScript
Harry J.W. Percival

#TDD
#Python
#Django
#Selenium
#JavaScript
#Clean_code
#REST_API
#Ajax
#workflow
#refactoring
#web_development
The third edition of this trusted guide demonstrates the practical advantages of test-driven development (TDD) with Python and describes how to develop a real web application. 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.
In the process, author Harry Percival teaches software and web developers the basics of Django, Selenium, Git, JavaScript, and Mock libraries, along with current web development techniques. This book--updated for Python 3.11 and Django 4--clearly demonstrates how TDD encourages simple designs and inspires confidence.
Fully updated, this third edition addresses:
Table of Contents
Part I. The Basics of TDD and Django
Chapter 1. Getting Django Set Up Using a Functional Test
Chapter 2. Extending Our Functional Test Using the unittest Module
Chapter 3. Testing a Simple Home Page with Unit Tests
Chapter 4. What Are We Doing with All lhese Tests? (And, Refactoring)
Chapter 5. Saving User Input: Testing the Database
Chapter 6. Improving Functional Tests: Ensuring Isolation and Removing Magic Sleeps
Chapter 7. Working Incrementally
Chapter 8. Prettification: Layout and Styling, and What to Test About It
Part II. Going to Production
Chapter 9. Containerization aka Docker
Chapter 10. Making Our App Production-Ready
Chapter 11. Getting a Server Ready for Deployment
Chapter 12. Infrastructure as Code: Automated Deployments with Ansible
Part Ill. Forms and Validation
Chapter 13. Splitting Our Tests into Multiple Files,
and a Generic Wait Helper
Chapter 14. Validation at the Database Layer
Chapter 15. A Simple Form
Chapter 16. More Advanced Forms
Part IV. More Advanced Topics in Testing
Chapter 17. A Gentle Excursion into JavaScript
Chapter 18. Deploying Our New Code
Chapter 19. User Authentication, Spiking, and De-Spiking
Chapter 20. Using Mocks to Test External Dependencies
Chapter 21. Using Mocks for Test Isolation
Chapter 22. Test Fixtures and a Decorator for Explicit Waits
Chapter 23. Debugging and Testing Server Issues
Chapter 24. Finishing "My Lists": Outside-In TDD
Chapter 25. Cl: Continuous Integration
Chapter 26. The Token Social Bit, the Page Pattern, and an Exercise for the Reader
Chapter 27. Fast Tests, Slow Tests, and Hot Lava
After an idyllic childhood spent playing with BASIC on French 8-bit computers like the Thomson T-07 whose keys go "boop" when you press them, Harry spent a few years being deeply unhappy as a management consultant. Soon he rediscovered his true geek nature, and was lucky enough to fall in with a bunch of XP fanatics, working on the pioneering but sadly defunct Resolver One spreadsheet. He now works at PythonAnywhere LLP, and spreads the gospel of TDD world-wide at talks, workshops and conferences, with all the passion and enthusiasm of a recent convert.









