Index
A
- acceptance test (see functional tests/testing (FT))
- acceptance tests, Fast Tests, Slow Tests, and Hot Lava
- aesthetics (see layout and style)
- agile movement in software development, Small Design When Necessary
- Ajax, The Server Side: Custom Authentication, QUnit setup and teardown, Testing Ajax
- ALLOWED_HOSTS, Switching DEBUG to False and Setting ALLOWED_HOSTS
- Anderson, Ross, Wiring Up Our Form to Send a POST Request
- Ansible, Further Reading, Provisioning with Ansible–Move Deployment out of Fabric and into Ansible
- any function, Using Selenium to Test User Interactions, A Little More of Our Front Page
- architectural solutions to test problems, Architectural Solutions
- assertion messages, The Python Standard Library’s unittest Module, The Python Standard Library’s unittest Module, Passing Python Variables to Be Rendered in the Template, A Simple Mock to Unit Tests Our initialize Function
- AssertionError, A Little More of Our Front Page
- assertRegex, Implementing the New Design Using TDD
- assertTemplateUsed, A Separate Template for Viewing Lists
- assertTrue, A Little More of Our Front Page
- asynchronous JavaScript, More Nested Callbacks! Testing Asynchronous Code–More Nested Callbacks! Testing Asynchronous Code
- authentication, User Authentication, Integrating Third-Party Plugins, and Mocking with JavaScript
- backend, De-spiking Our Custom Authentication Backend: Mocking Out an Internet Request–The get_user Method
- customising, The Server Side: Custom Authentication–The Server Side: Custom Authentication, A Look at Our Spiked Login View
- in Django, Checking the View Actually Logs the User In
- login view, Checking the View Actually Logs the User In–Checking the View Actually Logs the User In
- minimum custom user model, A Minimal Custom User Model–Users Are Authenticated
- mocking (see mocks/mocking)
- Mozilla Persona, Mozilla Persona (BrowserID)
- pre-authentication, Skipping the Login Process by Pre-creating a Session–Checking It Works
- testing logout, Finishing Off Our FT, Testing Logout
- testing view, Testing Our View by Mocking Out authenticate
- tests as documentation, Tests as Documentation
- automation, in deployment, TDD and the Danger Areas of Deployment, Automating Deployment with Fabric–Further Reading
- (see also deployment)
- automation, in provisioning, Further Reading
B
- Bash, Adjusting the Database Location
- Beck, Kent, Programming Is like Pulling a Bucket of Water up from a Well, On Refactoring
- Behavior-Driven Development (BDD) tools, Investigate a BDD Tool
- Bernhardt, Gary, Test Isolation, and “Listening to Your Tests”, Don’t Take It from Me, Functional Core, Imperative Shell
- best practices in testing, Fast Tests, Slow Tests, and Hot Lava
- Big Design Up Front, Small Design When Necessary
- black box test (see functional tests/testing (FT))
- Bootstrap, Prettification: Using a CSS Framework–Using Our Own CSS
- jumbotron, Jumbotron!
- large inputs, Large Inputs
- table styling, Table Styling
- boundaries, Ports and Adapters/Hexagonal/Clean Architecture
- browsers, Run Your Tests Against Different Browsers
- browsers, headless, Setting Up a Virtual Display so the FTs Can Run Headless
C
- caching, Caching and Performance Testing
- CI server (see continuous integration (CI))
- class-based generic views, Django Class-Based Views–Take-Home: Having Multiple, Isolated View Tests with Single Assertions Helps
- class-based views, Django Class-Based Views
- clean architecture, Ports and Adapters/Hexagonal/Clean Architecture
- code smell, Three Strikes and Refactor, Saving the POST to the Database, Moving Validation Logic into a Form, Finishing Off Our FT, Testing Logout
- collectstatic, What We Glossed Over: collectstatic and Other Static Directories–What We Glossed Over: collectstatic and Other Static Directories
- comments, Using a Functional Test to Scope Out a Minimum Viable App, Implementing the New Design Using TDD
- commits, Commit, Unit Testing in Django, urls.py, But How to Use That URL in the Form?
- configuration management tools, Further Reading
- (see also Fabric)
- context managers, Unit Testing Model Validation and the self.assertRaises Context Manager
- continuous integration (CI), Continuous Integration (CI)–More Things to Do with a CI Server, Keep Your CI Builds Green
- adding required plugins, Adding Required Plugins
- best practices, More Things to Do with a CI Server
- configuring Jenkins, Configuring Jenkins Security
- debugging with screenshots, Taking Screenshots–Taking Screenshots
- installing Jenkins, Installing Jenkins
- JavaScript tests, Running Our QUnit JavaScript Tests in Jenkins with PhantomJS–Adding the Build Steps to Jenkins
- project setup, Setting Up Our Project
- Selenium race conditions, A Common Selenium Problem: Race Conditions–A Common Selenium Problem: Race Conditions
- for staging server test automation, More Things to Do with a CI Server
- virtual display setup, Setting Up a Virtual Display so the FTs Can Run Headless–Setting Up a Virtual Display so the FTs Can Run Headless
- contracts, implicit, Identifying Implicit Contracts
- cookies, Checking the View Actually Logs the User In, Skipping the Login Process by Pre-creating a Session
- Cross-Site Request Forgery (CSRF) error, Wiring Up Our Form to Send a POST Request
- CSS (Cascading Style Sheets) framework, What to Functionally Test About Layout and Style, Prettification: Using a CSS Framework
- (see also Bootstrap)
- where Bootstrap won’t work, Using Our Own CSS
- cutting corners, Testing Is Hard
D
- data migrations, An Attempted Deploy to Staging–Conclusions
- database deployment issues, TDD and the Danger Areas of Deployment
- database location, Adjusting the Database Location
- De-spiking, De-spiking, De-spiking Our Custom Authentication Backend: Mocking Out an Internet Request–The get_user Method
- debugging, Testing a Simple Home Page with Unit Tests, Wiring Up Our Form to Send a POST Request, The Server Side: Custom Authentication
- Ajax, The Server Side: Custom Authentication
- Django debug screen, Simple Nginx Configuration
- improving error messages, Passing Python Variables to Be Rendered in the Template
- in continuous integration, Taking Screenshots–Taking Screenshots
- in JavaScript, A Simple Mock to Unit Tests Our initialize Function
- staging for, The Proof Is in the Pudding: Using Staging to Catch Final Bugs–Fixing the Persona Bug
- switching DEBUG to false, Switching DEBUG to False and Setting ALLOWED_HOSTS
- screenshots, for debugging, Taking Screenshots–Taking Screenshots
- dependencies
- and deployment, TDD and the Danger Areas of Deployment
- mocking out, Testing Our View by Mocking Out authenticate
- virtualenv, Creating a Virtualenv
- deployment, The Deployment Chapter
- adjusting database location, Adjusting the Database Location
- automating, Automating–Automating, Automating Deployment with Fabric–Further Reading
- danger areas, TDD and the Danger Areas of Deployment
- dependencies and, TDD and the Danger Areas of Deployment
- deploying to live, Deploying to Live
- further reading, Further Reading
- key points, Automating
- to live, Live Deploy
- migrate, Creating the Database with migrate
- Nginx, Simple Nginx Configuration–Simple Nginx Configuration
- overview, Automating
- production-ready, Getting to a Production-Ready Deployment–Saving Our Changes: Adding Gunicorn to Our requirements.txt
- vs. provisioning, Deploying Our Code Manually
- sample script, Breakdown of a Fabric Script for Our Deployment–Breakdown of a Fabric Script for Our Deployment
- saving progress, “Saving Your Progress”
- staging, Staging Deploy, An Attempted Deploy to Staging
- virtualenvs, Creating a Virtualenv–Creating a Virtualenv
- deployment testing, Testing Deployment Using a Staging Site–“Saving Your Progress”
- domain name for, Getting a Domain Name
- manual provisioning for hosting, Manually Provisioning a Server to Host Our Site–Using the FT to Confirm the Domain Works and Nginx Is Running
- overview, TDD and the Danger Areas of Deployment
- design (see layout and style)
- Django, Obey the Testing Goat! Do Nothing Until You Have a Test
- admin site, The Django Admin Site
- apps, Our First Django App, and Our First Unit Test
- authentication in, The Server Side: Custom Authentication–The Server Side: Custom Authentication, Checking the View Actually Logs the User In
- class-based views, Django Class-Based Views–Take-Home: Having Multiple, Isolated View Tests with Single Assertions Helps
- (see also class-based views)
- collectstatic, What We Glossed Over: collectstatic and Other Static Directories–What We Glossed Over: collectstatic and Other Static Directories
- custom user model, A Minimal Custom User Model–Users Are Authenticated
- debugging screen, Simple Nginx Configuration, Switching DEBUG to False and Setting ALLOWED_HOSTS
- field types, The Test Gets Surprisingly Far
- foreign key relationship, A Foreign Key Relationship
- forms in (see forms)
- FormView, The Home Page as a FormView
- functional tests (FT) in (see functional tests/testing (FT))
- and Gunicorn, Switching to Gunicorn
- LiveServerTestCase, Ensuring Test Isolation in Functional Tests
- management commands, A Django Management Command to Create Sessions–Getting the FT to Run the Management Command on the Server, Wrap-Up
- migrations, Our First Database Migration–A New Field Means a New Migration, Creating Our Production Database with migrate–Creating Our Production Database with migrate, Deploying Our New Code
- model adjustment in, Adjusting Our Models
- model-layer validation, Using Model-Layer Validation–Enforcing Model Validation in view_list
- Model-View-Controller (MVC), Django’s MVC, URLs, and View Functions
- notifications, Notifications—Both on the Site and by Email
- Object-Relational Mapper (ORM), The Django ORM and Our First Model–A New Field Means a New Migration
- POST requests (see POST requests)
- as PythonAnywhere app, Setting Up Django as a PythonAnywhere Web App
- startproject, Getting Django Up and Running
- static files in, Static Files in Django
- static live server case, Switching to StaticLiveServerTestCase
- template inheritance, Django Template Inheritance–Django Template Inheritance
- templates, Rendering Items in the Template–Rendering Items in the Template, A Separate Template for Viewing Lists
- test class in, A Test Class for New List Creation
- test client, A New Test Class, A Test Class for New List Creation
- test fixtures, Skipping the Login Process by Pre-creating a Session
- TestCase, Unit Testing in Django
- unit testing in, Unit Testing in Django
- URLs in, Django’s MVC, URLs, and View Functions–urls.py, A New URL, A URL and View for New List Creation, Pointing Our Forms at the New URL, Each List Should Have Its Own URL, The Last New URL, But How to Use That URL in the Form?, A Final Refactor Using URL includes
- validation quirk, A Django Quirk: Model Save Doesn’t Run Validation
- view functions in, Django’s MVC, URLs, and View Functions, A New View Function, A URL and View for New List Creation, One More View to Handle Adding Items to an Existing List–The Last New View, Moving Down One Layer to View Functions (the Controller)
- and virtualenvs, Creating a Virtualenv–Creating a Virtualenv
- Django-BrowserID, Exploratory Coding, aka “Spiking”
- documentation, tests as, Tests as Documentation
- domain names, Getting a Domain Name
- Don’t Test Constants rule, The “Don’t Test Constants” Rule, and Templates to the Rescue
- double-loop TDD, Recap: The TDD Process, Finishing “My Lists”: Outside-In TDD
- DRY (don’t repeat yourself), Three Strikes and Refactor, An Exercise for the Reader
- duplicates, eliminating, Passing Python Variables to Be Rendered in the Template, Another FT for Duplicate Items–A More Complex Form to Handle Uniqueness Validation
E
- encryption, Client-Side Encryption
- end-to-end test (see functional tests/testing (FT))
- error messages, Test for Graceful Degradation
- error pages, 404 and 500 Tests
- evaluating third-party systems, De-spiking
- expected failure, Using a Functional Test to Scope Out a Minimum Viable App, Commit
- explicit waits, A Common Selenium Technique: Explicit Waits
- exploratory coding, Exploring the Forms API with a Unit Test, Exploratory Coding, aka “Spiking”
- (see also spiking)
F
- Fabric, Further Reading, An Additional Hop via subprocess, Move Deployment out of Fabric and into Ansible
- configuration, Trying It Out
- installing, Automating Deployment with Fabric
- sample deployment script, Breakdown of a Fabric Script for Our Deployment–Breakdown of a Fabric Script for Our Deployment
- Fake XMLHttpRequest, QUnit setup and teardown, Testing Ajax
- fixtures
- in functional tests, Skipping the Login Process by Pre-creating a Session
- in JavaScript tests, Using jQuery and the Fixtures Div
- on staging server, Managing the Test Database on Staging–An Additional Hop via subprocess
- foreign key relationship, A Foreign Key Relationship
- forms
- advanced, More Advanced Forms–Using the Existing List Item Form in the List View
- autogeneration, Switching to a Django ModelForm
- customising form field input, Exploring the Forms API with a Unit Test
- experimenting with, Exploring the Forms API with a Unit Test
- ModelForm, Switching to a Django ModelForm
- save methods, Using the Form’s Own Save Method
- simple, A Simple Form–Using the Form’s Own Save Method
- thin views, Using the Form’s Own Save Method
- tips for, Using the Form’s Own Save Method
- using in views, Using the Form in Our Views–A Helper Method for Several Short Tests
- validation testing and customising, Testing and Customising Form Validation
- Functional Core, Imperative Shell architecture, Functional Core, Imperative Shell
- functional tests/testing (FT), Obey the Testing Goat! Do Nothing Until You Have a Test, Fast Tests, Slow Tests, and Hot Lava
- automation of (see continuous integration (CI))
- cleanup, Getting to the Minimum Viable Site–Ensuring Test Isolation in Functional Tests, Removing Now-Redundant Code and Tests, An FT with Multiple Users, and addCleanup
- de-duplication, Wrap-Up
- defining, Using a Functional Test to Scope Out a Minimum Viable App
- for de-spiking, De-spiking
- for duplicate items, Another FT for Duplicate Items–A More Complex Form to Handle Uniqueness Validation
- isolation in, Getting to the Minimum Viable Site–Ensuring Test Isolation in Functional Tests, A Final Refactor Using URL includes
- in JavaScript, Building a JavaScript Unit Test for Our Desired Functionality–Javascript Testing in the TDD Cycle
- for layout and style, What to Functionally Test About Layout and Style–What to Functionally Test About Layout and Style, Switching to Gunicorn, Splitting Functional Tests out into Many Files
- multiple users, An FT with Multiple Users, and addCleanup, Extend the FT to a Second User, and the “My Lists” Page–Extend the FT to a Second User, and the “My Lists” Page
- pros and cons, Onwards!
- in provisioning, Using the FT to Confirm the Domain Works and Nginx Is Running
- running unit tests only, Running Just the Unit Tests
- safeguards with, An Additional Hop via subprocess
- splitting, Splitting Functional Tests out into Many Files
- for staging sites, TDD and the Danger Areas of Deployment, As Always, Start with a Test
- unittest module, Extending Our Functional Test Using the unittest Module–Commit
- vs. unit tests, Unit Tests, and How They Differ from Functional Tests, Test Fixtures, Logging, and Server-Side Debugging
- in views, Using the Existing List Item Form in the List View
G
- generator expression, Using Selenium to Test User Interactions
- GET requests, Using the Form in a View with a GET Request, Using the Form in the Other View
- get_user, The get_user Method
- Git
- repository setup, Starting a Git Repository–Starting a Git Repository
- reset --hard, What to Functionally Test About Layout and Style
- tags, Git Tag the Release, Wrap-Up: git tag the New Release
- global variables, Setting Up a Basic JavaScript Test Runner
- greedy regular expressions, Beware of Greedy Regular Expressions!
- Gunicorn, Switching to Gunicorn–Automating, Nginx and Gunicorn Config Using sed, Setting Up Logging, Configuring Gunicorn, and Using Handlers to Restart Services
H
- headless browsers, Setting Up a Virtual Display so the FTs Can Run Headless
- helper functions/methods, Three Strikes and Refactor, Splitting Functional Tests out into Many Files, Fleshing Out the FT, A Helper Method for Several Short Tests, Starting with an FT, Keep Listening to Your Tests: Removing ORM Code from Our Application, The Page Pattern–The Page Pattern
- hexagonal architecture, Ports and Adapters/Hexagonal/Clean Architecture
- hosting options, Choosing Where to Host Our Site
- hosting, manual provisioning, Manually Provisioning a Server to Host Our Site–Using the FT to Confirm the Domain Works and Nginx Is Running
I
- Idempotency, Further Reading
- implicit waits, Implicit waits
- in-memory model objects, Finally, Moving Down to the Models Layer
- integrated tests, Finally, Moving Down to the Models Layer–Onwards!, Ports and Adapters/Hexagonal/Clean Architecture
- vs. integration test, Keep the Old Integrated Test Suite Around as a Sanity Check
- vs. isolated tests, Conclusions: When to Write Isolated Versus Integrated Tests, Fast Tests, Slow Tests, and Hot Lava
- pros and cons, Onwards!
- vs. unit tests, The Django ORM and Our First Model
- integration tests, Keep the Old Integrated Test Suite Around as a Sanity Check, Fast Tests, Slow Tests, and Hot Lava
- integrity errors, Some Integrity Errors Do Show Up on Save
- isolated tests, Test Isolation, and “Listening to Your Tests”, Ports and Adapters/Hexagonal/Clean Architecture
- (see also test isolation)
- vs. integrated tests, Conclusions: When to Write Isolated Versus Integrated Tests, Fast Tests, Slow Tests, and Hot Lava
- problems with, Isolated Tests Can Be Harder to Read and Write
- pros and cons, Onwards!
J
- JavaScript, Dipping Our Toes, Very Tentatively, into JavaScript
- de-spiking in, De-spiking
- debug console, A Simple Mock to Unit Tests Our initialize Function
- functional test (FT) building in, Building a JavaScript Unit Test for Our Desired Functionality–Javascript Testing in the TDD Cycle
- jQuery and Fixtures Div, Using jQuery and the Fixtures Div–Using jQuery and the Fixtures Div
- linters, Setting Up a Basic JavaScript Test Runner
- MVC frameworks, JavaScript MVC Frameworks
- onload boilerplate and namespacing, Columbo Says: Onload Boilerplate and Namespacing
- QUnit, Setting Up a Basic JavaScript Test Runner
- running tests in continuous integration, Running Our QUnit JavaScript Tests in Jenkins with PhantomJS–Adding the Build Steps to Jenkins
- spiking with, Exploratory Coding, aka “Spiking”–Reverting Our Spiked Code
- (see also spiking)
- in TDD Cycle, Javascript Testing in the TDD Cycle
- test runner setup, Setting Up a Basic JavaScript Test Runner
- testing notes, A Few Things That Didn’t Make It
- Jenkins Security, Installing Jenkins–Adding the Build Steps to Jenkins
- (see also continuous integration (CI))
- adding required plugins, Adding Required Plugins
- configuring, Configuring Jenkins Security
- installing, Installing Jenkins
- jQuery, Using jQuery and the Fixtures Div–Using jQuery and the Fixtures Div, Columbo Says: Onload Boilerplate and Namespacing, A Few Things That Didn’t Make It
- JSON fixtures, Skipping the Login Process by Pre-creating a Session, Wrap-Up
- jumbotron, Jumbotron!
L
- layout and style, Prettification: Layout and Styling, and What to Test About It–A Few Things That Didn’t Make It
- Bootstrap for (see Bootstrap)
- functional tests (FT) for, Splitting Functional Tests out into Many Files
- large inputs, Large Inputs
- overview, A Few Things That Didn’t Make It
- rows and columns, Rows and Columns
- static files, Static Files in Django, What We Glossed Over: collectstatic and Other Static Directories–What We Glossed Over: collectstatic and Other Static Directories
- table styling, Table Styling
- using a CSS framework for, Prettification: Using a CSS Framework
- (see also Bootstrap)
- using our own CSS in, Using Our Own CSS
- what to functionally test for, What to Functionally Test About Layout and Style
- list comprehension, Using Selenium to Test User Interactions
- LiveServerTestCase, Ensuring Test Isolation in Functional Tests
- log messages, Wrap-Up
- logging, Setting Up Logging, Wrap-Up
- logging configuration, Using Hierarchical Logging Config–Wrap-Up
M
- manage.py, Getting Django Up and Running, Unit Testing in Django, Our First Database Migration, Creating Our Production Database with migrate, What We Glossed Over: collectstatic and Other Static Directories
- Meta, Switching to a Django ModelForm
- meta-comments, Implementing the New Design Using TDD
- migrate, Creating the Database with migrate
- migrations, Our First Database Migration–A New Field Means a New Migration, Creating Our Production Database with migrate–Creating Our Production Database with migrate, A Foreign Key Relationship, Deploying Our New Code, What to Do If You See a Database Error
- (see also data migrations)
- database, Testing Database Migrations–Conclusions
- deleting, A Foreign Key Relationship
- testing, Testing Database Migrations–Conclusions
- minimum viable application, Using a Functional Test to Scope Out a Minimum Viable App–Using a Functional Test to Scope Out a Minimum Viable App, Small Design When Necessary
- MockMyID, De-spiking
- mocks/mocking
- callbacks, More Nested Callbacks! Testing Asynchronous Code–More Nested Callbacks! Testing Asynchronous Code
- checking call arguments, Checking Call Arguments
- implicit contracts, Identifying Implicit Contracts
- in JavaScript, User Authentication, Integrating Third-Party Plugins, and Mocking with JavaScript, Mocking: Who, Why, What?–More Nested Callbacks! Testing Asynchronous Code
- initialize function test, A Simple Mock to Unit Tests Our initialize Function–A Simple Mock to Unit Tests Our initialize Function
- Internet requests, De-spiking Our Custom Authentication Backend: Mocking Out an Internet Request–The get_user Method
- for isolation, A First Attempt at Using Mocks for Isolation–Using Mock side_effects to Check the Sequence of Events
- mock library, Finishing Off Our FT, Testing Logout
- Mock side_effects, Using Mock side_effects to Check the Sequence of Events
- namespacing, Namespacing
- in Outside-In TDD, A Decision Point: Whether to Proceed to the Next Layer with a Failing Test
- in Python, Mocking in Python–Checking the View Actually Logs the User In
- risks, The Moment of Truth (and the Risks of Mocking)
- sinon.js, Using a sinon.js mock to check we call the API correctly
- testing Django login, Checking the View Actually Logs the User In
- model-layer validation, Using Model-Layer Validation–Enforcing Model Validation in view_list
- changes to test, Rewriting the Old Model Test
- enforcing, Enforcing Model Validation in view_list
- errors in View, Surfacing Model Validation Errors in the View–Checking Invalid Input Isn’t Saved to the Database
- integrity errors, Some Integrity Errors Do Show Up on Save
- POST requests, Django Pattern: Processing POST Requests in the Same View as Renders the Form–Enforcing Model Validation in view_list
- preventing duplicates, Preventing Duplicates at the Model Layer
- refactoring, Refactoring Unit Tests into Several Files, Refactor: Transferring the new_item Functionality into view_list–Refactor: Transferring the new_item Functionality into view_list
- unit testing, Unit Testing Model Validation and the self.assertRaises Context Manager–A Django Quirk: Model Save Doesn’t Run Validation
- at views level, Experimenting with Duplicate Item Validation at the Views Layer
- Model-View-Controller (MVC), Django’s MVC, URLs, and View Functions, JavaScript MVC Frameworks
- ModelForm, Switching to a Django ModelForm
- Mozilla Persona, Mozilla Persona (BrowserID)
- MVC frameworks, Django’s MVC, URLs, and View Functions, JavaScript MVC Frameworks
N
- namespacing, Namespacing
- Nginx, Installing Nginx, Simple Nginx Configuration–Simple Nginx Configuration, Getting Nginx to Serve Static Files, Nginx and Gunicorn Config Using sed, Installing System Packages and Nginx
- nonroot user creation, User Accounts, SSH, and Privileges
- notifications, Notifications—Both on the Site and by Email
O
- ORM (Object-Relational Mapper), The Django ORM and Our First Model–A New Field Means a New Migration
- Outside-In TDD, Finishing “My Lists”: Outside-In TDD–Final Step: Feeding Through the .name API from the Template
- advantages, Why Prefer “Outside-In”?
- controller layer, Moving Down One Layer to View Functions (the Controller)
- defined, Final Step: Feeding Through the .name API from the Template
- vs. Inside-Out, The Alternative: “Inside Out”
- model layer, The Next “Requirement” from the Views Layer: New Lists Should Record Owner–Moving Down to the Model Layer
- pitfalls, Final Step: Feeding Through the .name API from the Template
- presentation layer, The Outside Layer: Presentation and Templates
- template hierarchy, A Quick Restructure of the Template Inheritance Hierarchy–Moving Down to the Next Layer: What the View Passes to the Template
- views layer, Moving Down One Layer to View Functions (the Controller)–The Next “Requirement” from the Views Layer: New Lists Should Record Owner, Moving Down to the Model Layer
P
- PaaS (Platform-as-a-Service), Choosing Where to Host Our Site
- Page pattern, The Page Pattern–The Page Pattern, An Exercise for the Reader
- patch decorator, Testing Our View by Mocking Out authenticate, Finishing Off Our FT, Testing Logout
- patching, Patching at the Class Level
- payment systems, testing for, De-spiking
- performance testing, Caching and Performance Testing
- Persona, Mozilla Persona (BrowserID), De-spiking, Setting Up Logging–Fixing the Persona Bug, Test for Graceful Degradation
- PhantomJS, Running Our QUnit JavaScript Tests in Jenkins with PhantomJS–Adding the Build Steps to Jenkins, Run Your Tests Against Different Browsers
- Platform-as-a-Service (PaaS), Choosing Where to Host Our Site
- POST requests, Using the Form in a View That Takes POST Requests
- processing, Processing a POST Request on the Server, Django Pattern: Processing POST Requests in the Same View as Renders the Form–Enforcing Model Validation in view_list
- redirect after, Redirect After a POST
- saving to database, Saving the POST to the Database–Saving the POST to the Database
- sending, Wiring Up Our Form to Send a POST Request–Wiring Up Our Form to Send a POST Request, A Separate Template for Viewing Lists
- Postgres, Switch to Postgres
- private key authentication, User Accounts, SSH, and Privileges
- programming by wishful thinking, Designing Our API Using the Template, Final Step: Feeding Through the .name API from the Template
- (see also Outside-In TDD)
- property Decorator, Final Step: Feeding Through the .name API from the Template
- provisioning, Manually Provisioning a Server to Host Our Site–Using the FT to Confirm the Domain Works and Nginx Is Running
- with Ansible, Provisioning with Ansible–Move Deployment out of Fabric and into Ansible
- automation in, Further Reading
- functional tests (FT) in, Using the FT to Confirm the Domain Works and Nginx Is Running
- overview, Automating
- vs. deployment, Deploying Our Code Manually
- pure unit tests (see isolated tests)
- py.test, Switch to Using py.test
- Python
- adding to Jenkins, Telling Jenkins where to find Python 3 and Xvfb
- PythonAnywhere, Choosing Where to Host Our Site, PythonAnywhere
Q
- QuerySet, The Django ORM and Our First Model, A Little Digression on Queryset Ordering and String Representations–A Little Digression on Queryset Ordering and String Representations
- QUnit, Setting Up a Basic JavaScript Test Runner, A Few Things That Didn’t Make It, A Simple Mock to Unit Tests Our initialize Function, QUnit setup and teardown, Testing Ajax
R
- race conditions, Setting Up a Virtual Display so the FTs Can Run Headless, Implementing the Selenium Interact/Wait Pattern
- Red, Green, Refactor, Passing Python Variables to Be Rendered in the Template, Green? Refactor, Skipping a Test
- redirects, Redirect After a POST, Using get_absolute_url for Redirects
- refactoring, Refactoring to Use a Template–On Refactoring
- at application level, Django Pattern: Processing POST Requests in the Same View as Renders the Form–Refactor: Transferring the new_item Functionality into view_list
- Red, Green, Refactor, Passing Python Variables to Be Rendered in the Template, Green? Refactor, Skipping a Test
- removing hard-coded URLs, Refactor: Removing Hardcoded URLs
- and test isolation, Listen to Your Tests: Ugly Tests Signal a Need to Refactor, Conclusions: When to Write Isolated Versus Integrated Tests
- tips, Using get_absolute_url for Redirects
- unit tests, Refactoring Unit Tests into Several Files
- Refactoring Cat, On Refactoring, A Final Refactor Using URL includes
- relative import, Breakdown of a Fabric Script for Our Deployment, Splitting Functional Tests out into Many Files
- render to string, Passing Python Variables to Be Rendered in the Template
- REST (Representational Site Transfer), REST
S
- screenshots, Screenshots
- scripts, automated, TDD and the Danger Areas of Deployment
- secret key, Breakdown of a Fabric Script for Our Deployment
- Security Engineering (Anderson), Wiring Up Our Form to Send a POST Request
- security tests, Write Some Security Tests
- sed (stream editor), Nginx and Gunicorn Config Using sed
- Selenium, Obey the Testing Goat! Do Nothing Until You Have a Test
- and JavaScript, A Few Things That Didn’t Make It
- best practices, More Things to Do with a CI Server
- in continuous integration, A Common Selenium Problem: Race Conditions–A Common Selenium Problem: Race Conditions
- in continuous integration, First Build!
- race conditions, Implementing the Selenium Interact/Wait Pattern
- race conditions in, A Common Selenium Problem: Race Conditions–A Common Selenium Problem: Race Conditions
- upgrading, Implementing the New Design Using TDD
- for user interaction testing, Using Selenium to Test User Interactions–The “Don’t Test Constants” Rule, and Templates to the Rescue
- wait patterns, Implicit waits, A Common Selenium Technique: Explicit Waits, The Token Social Bit, the Page Pattern, and an Exercise for the Reader, Implementing the Selenium Interact/Wait Pattern
- waits in, A Common Selenium Problem: Race Conditions–A Common Selenium Problem: Race Conditions, More Things to Do with a CI Server
- server configuration, Automating
- server options, Spinning Up a Server
- servers, Manually Provisioning a Server to Host Our Site–Using the FT to Confirm the Domain Works and Nginx Is Running
- (see also staging server)
- session key, Skipping the Login Process by Pre-creating a Session
- sessions, Checking the View Actually Logs the User In
- Shining Panda, Telling Jenkins where to find Python 3 and Xvfb
- sinon.js, Using a sinon.js mock to check we call the API correctly, QUnit setup and teardown, Testing Ajax, More Nested Callbacks! Testing Asynchronous Code
- skips, Skipping a Test
- spiking, Exploratory Coding, aka “Spiking”–Reverting Our Spiked Code, More Nested Callbacks! Testing Asynchronous Code
- browser-ID protocol, The Browser-ID Protocol
- de-spiking, De-spiking
- frontend and JavaScript code, Frontend and JavaScript Code
- logging, The Server Side: Custom Authentication
- server-side authentication, The Server Side: Custom Authentication–The Server Side: Custom Authentication
- with JavaScript, Exploratory Coding, aka “Spiking”
- SQLite, Switch to Postgres
- staging server
- creating sessions, A Django Management Command to Create Sessions
- debugging in, The Proof Is in the Pudding: Using Staging to Catch Final Bugs–Fixing the Persona Bug
- managing database on, Managing the Test Database on Staging–Checking It Works
- test automation with CI, More Things to Do with a CI Server
- staging sites, TDD and the Danger Areas of Deployment, As Always, Start with a Test, Getting a Domain Name
- static files, What to Functionally Test About Layout and Style, Static Files in Django, TDD and the Danger Areas of Deployment, Getting Nginx to Serve Static Files
- static folder, site-wide, Housekeeping: A Site-Wide Static Files Folder
- static live server case, Switching to StaticLiveServerTestCase
- string representation, A Little Digression on Queryset Ordering and String Representations
- string substitutions, Each List Should Have Its Own URL
- style (see layout and style)
- superlists, Starting a Git Repository
- system boundaries, Ports and Adapters/Hexagonal/Clean Architecture
- system tests, Fast Tests, Slow Tests, and Hot Lava
T
- table styling, Table Styling
- template inheritance, Django Template Inheritance–Django Template Inheritance
- template inheritance hierarchy, A Quick Restructure of the Template Inheritance Hierarchy
- template tag, Wiring Up Our Form to Send a POST Request
- templates, Refactoring to Use a Template, Passing Python Variables to Be Rendered in the Template
- rendering items in, Rendering Items in the Template–Rendering Items in the Template
- separate, A Separate Template for Viewing Lists
- test fixtures, Skipping the Login Process by Pre-creating a Session, Wrap-Up
- test isolation, A Final Refactor Using URL includes, Test Isolation, and “Listening to Your Tests”–Onwards!
- cleanup after, Tidy Up: What to Keep from Our Integrated Test Suite–Removing Redundant Code at the Forms Layer
- collaborators, Thinking in Terms of Collaborators–Thinking in Terms of Collaborators
- complexity in, Let Complexity Be Your Guide
- forms layer, Moving Down to the Forms Layer–Keep Listening to Your Tests: Removing ORM Code from Our Application
- full isolation, Rewriting Our Tests for the View to Be Fully Isolated
- interactions between layers, Thinking of Interactions Between Layers as “Contracts”
- isolated vs. integrated tests, Conclusions: When to Write Isolated Versus Integrated Tests
- mocks/mocking for, A First Attempt at Using Mocks for Isolation–Using Mock side_effects to Check the Sequence of Events
- models layer, Finally, Moving Down to the Models Layer–Finally, Moving Down to the Models Layer
- ORM code, Moving Down to the Forms Layer–Keep Listening to Your Tests: Removing ORM Code from Our Application, Onwards!
- refactoring in, Listen to Your Tests: Ugly Tests Signal a Need to Refactor, Conclusions: When to Write Isolated Versus Integrated Tests
- views layer, Revisiting Our Decision Point: The Views Layer Depends on Unwritten Models Code, A First Attempt at Using Mocks for Isolation–Thinking in Terms of Collaborators, Back to Views
- test methods, The Python Standard Library’s unittest Module
- test organisation, Using get_absolute_url for Redirects
- test skips, Skipping a Test
- test types, Onwards!, Fast Tests, Slow Tests, and Hot Lava
- test-driven development (TDD)
- advanced considerations in, Fast Tests, Slow Tests, and Hot Lava–Conclusion
- and developer stupidity, Preventing Duplicates at the Model Layer
- double-loop, Recap: The TDD Process, Finishing “My Lists”: Outside-In TDD
- further reading on, Conclusion
- Inside-Out, The Alternative: “Inside Out”
- iterating towards new design, Iterating Towards the New Design
- Java testing in, Javascript Testing in the TDD Cycle
- justifications for, What Are We Doing with All These Tests?–Programming Is like Pulling a Bucket of Water up from a Well
- new design implementation with, Implementing the New Design Using TDD–Implementing the New Design Using TDD
- Outside-In, Finishing “My Lists”: Outside-In TDD–Final Step: Feeding Through the .name API from the Template
- (see also Outside-In TDD)
- process flowchart, Implementing the New Design Using TDD
- process recap, Recap: The TDD Process–Recap: The TDD Process
- trivial tests, Programming Is like Pulling a Bucket of Water up from a Well–Programming Is like Pulling a Bucket of Water up from a Well
- Working state to working state, Iterating Towards the New Design, But How to Use That URL in the Form?, A Final Refactor Using URL includes
- testing best practices, Fast Tests, Slow Tests, and Hot Lava
- Testing Goat, Obey the Testing Goat! Do Nothing Until You Have a Test, But How to Use That URL in the Form?, A Final Refactor Using URL includes, Testing Is Hard
- tests, as documentation, Tests as Documentation
- thin views, Using the Form’s Own Save Method
- time.sleep, Wiring Up Our Form to Send a POST Request
- tracebacks, At Last! We Actually Write Some Application Code!, Passing Python Variables to Be Rendered in the Template
- triangulation, Passing Python Variables to Be Rendered in the Template
U
- Ubuntu, Spinning Up a Server
- unit tests
- architectural solutions for, Architectural Solutions
- context manager, Unit Testing Model Validation and the self.assertRaises Context Manager
- desired features of, Synthesis: What Do We Want from Our Tests, Anyway?
- in Django, Unit Testing in Django
- for simple home page, Testing a Simple Home Page with Unit Tests–The Unit-Test/Code Cycle
- vs. functional tests, Test Fixtures, Logging, and Server-Side Debugging
- vs. functional tests (FT), Unit Tests, and How They Differ from Functional Tests
- vs. integrated tests, The Django ORM and Our First Model
- pros and cons of, Thesis: Unit Tests Are Superfast and Good Besides That–But All These Problems Can Be Overcome
- refactoring, Refactoring Unit Tests into Several Files
- unit-test/code cycle, The Unit-Test/Code Cycle–The Unit-Test/Code Cycle
- unittest, As Always, Start with a Test
- Unix sockets, Switching to Using Unix Sockets
- Upstart, Using Upstart to Make Sure Gunicorn Starts on Boot
- URLs
- capturing parameters in, Capturing Parameters from URLs
- distinct, Each List Should Have Its Own URL
- in Django, Django’s MVC, URLs, and View Functions–urls.py, A New URL, A URL and View for New List Creation, Pointing Our Forms at the New URL, Each List Should Have Its Own URL, The Last New URL, But How to Use That URL in the Form?
- pointing forms to, Pointing Our Forms at the New URL
- urls.py, urls.py–urls.py
- user authentication (see authentication)
- user creation, Creating a User if Necessary
- user input, saving, Saving User Input–Creating Our Production Database with migrate
- user interaction testing, Using Selenium to Test User Interactions–The “Don’t Test Constants” Rule, and Templates to the Rescue
- user stories, Commit, Validation FT: Preventing Blank Items
V
- Vagrant, Use Vagrant to Spin Up a Local VM
- validation, Validation FT: Preventing Blank Items
- (see also functional tests/testing (FT))
- model-layer, Using Model-Layer Validation–Enforcing Model Validation in view_list
- (see also model-layer validation)
- VCS (version control system), Starting a Git Repository–Starting a Git Repository
- view functions, in Django, Django’s MVC, URLs, and View Functions, A New View Function, A URL and View for New List Creation, One More View to Handle Adding Items to an Existing List–The Last New View
- views layer, Revisiting Our Decision Point: The Views Layer Depends on Unwritten Models Code, A First Attempt at Using Mocks for Isolation–Thinking in Terms of Collaborators, Back to Views
- model validation errors in, Surfacing Model Validation Errors in the View–Checking Invalid Input Isn’t Saved to the Database
- views, what to test in, Using the Existing List Item Form in the List View
- virtual displays, Setting Up a Virtual Display so the FTs Can Run Headless
- Virtualbox, Use Vagrant to Spin Up a Local VM
- virtualenvs, TDD and the Danger Areas of Deployment, Creating a Virtualenv–Creating a Virtualenv
W
- waits, Implicit waits, A Common Selenium Technique: Explicit Waits, A Common Selenium Problem: Race Conditions–A Common Selenium Problem: Race Conditions, More Things to Do with a CI Server, The Token Social Bit, the Page Pattern, and an Exercise for the Reader, Implementing the Selenium Interact/Wait Pattern
- warnings, The Python Standard Library’s unittest Module
- watch function, More Advanced Mocking
- websockets, Async and Websockets
- widgets, Exploring the Forms API with a Unit Test, Switching to a Django ModelForm
X
Y
- YAGNI, YAGNI!
Get Test-Driven Development with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.