When it comes to testing, the "edges" of the application are often the hardest. How do I test if my application has sent an email reliably? Should I setup an email server? How about a third-party API, should I use their testing environment or try to monkey patch the socket connection?
How about databases? Do I use a real db server, mock objects, or fixtures for testing? How do I prevent cross-test data contamination? What about testing database migrations?
In this tutorial, we will build a demo application called the "PYPI Bandwidth Calculator." It will have the following features:
- the main feature of the application will be to calculate the bandwidth used by packages on PYPI
- web and/or CLI interface depending on experience & desire of the student
- user will enter the name of a PYPI package and the app will display the bandwidth that package has used
- package size & download number will be retrieved from PYPI JSON interface
- the bandwidth will be cached in a local database, expires every 5 minutes
- an email will be sent to the administrators/developers if PYPI is down or throws an error
- if students have time, more advanced features can be added to the app
The main point of the tutorial will be to give the student experience testing the "edge" cases of an application. In particular, the app as described above will provide opportunity to gain experience in testing:
- web or CLI user interfaces
- third-party API services, including error handling and unexpected responses
- database interactions
- time-based interactions