SitePoint
Blog
Forum
Library
Login
Join Premium
Toggle sidebar
Clean Architectures in Python
Toggle community discussions
Close
Content
Bookmarks
Preface
Clean Architectures in Python
Introduction
What is a software architecture?
Why is it called “clean” architecture?
Why Python?
Acknowledgments
About the book
A brief history of this book
How this book is structured
Typographic conventions
Why this book comes for free
Submitting issues or patches
About the author
Setup a Python Project
Virtual environments
Python projects with Cookiecutter
1
Introduction to TDD
Introduction
A real-life example
A simple TDD project
Setup the project
Requirements
Step 1 - Adding two numbers
Step 2 - Adding three numbers
Step 3 - Adding multiple numbers
Step 4 - Subtraction
Step 5 - Multiplication
Step 6 - Refactoring
Step 7 - Division
Step 8 - Testing exceptions
Step 9 - A more complex set of requirements
Recap of the TDD rules
How many assertions?
How to manage bugs or missing features
On unit testing
Introduction
Tests should be fast
Tests should be idempotent
Tests should be isolated
External systems
Focus on messages
The testing grid
Conclusions
Mocks
Basic concepts
First steps
Simple return values
Complex return values
Asserting calls
A simple example
Patching
The patching decorator
Multiple patches
Patching immutable objects
Mocks and proper TDD
A warning
Recap
Components of a clean architecture
Layers and data flow
Main layers
APIs and shades of grey
A basic example
Project overview
Project setup
Domain models
Serializers
Use cases
The storage system
A command-line interface
HTTP API
Conclusions
Error management
Introduction
Basic requests and responses
Requests and responses in a use case
Request validation
Responses and failures
Error management in a use case
Integrating external systems
The HTTP server
The repository
Conclusions
Database repositories
Introduction
A repository based on PostgreSQL
A repository based on MongoDB
Conclusions
Changelog
Notes
Introduction
About the book
Chapter 1 - Introduction to TDD
Chapter 2 - On unit testing
Chapter 3 - Mocks
Chapter 1 - Components of a clean architecture
Chapter 2 - A basic example
Chapter 3 - Error management
Chapter 4 - Database repositories
Open text modal
Community Questions
Close