Dailies

Instructor’s Coding Log

While the students worked on team projects, the instructor applied code quality and other software engineering tools to the scaffolding projects that had been introduced at the beginning of class. These are the dailies from that work.

These notes are organized by when the work was done, so there’s a bit of hopping between topics, and returning to topics a few days later.

Python Unit Tests Unit tests, stubs, mocks, and spies — oh my! We’ll use PyTest to add unit tests to Bear-as-a-Service.

Continuous Integration A Continuous Integration (CI) server runs tests against every pushed commit. We’ll add unit tests to Bear-as-a-Service, and connect the GitHub repo to the Travis CI service.

Continuous Delivery A Continuous Delivery system automatically (and continuously) delivers your application to the user. For an internet service such as a web application or another service that is running in the cloud, this means automatically deploying new versions that pass a quality checkpoint to a user-visible environment. We’ll look at how to do this with a Flask (Python) application, the Travis CI server, and Heroku.

Twilio, Web Hooks, and ngrok A web hooks notifies a web application of an external event. Configuring Twilio to connect to your application. Using ngrok to proxy web hooks to your development laptop.

Keeping Secrets How to keep passwords, API keys, and other secrets out of GitHub.

Linting Your Code A linter is a code quality tool that examines your source against style guides, and looks for patterns associated with maintenance issues and outright bugs. This post applies a linter to Bear-as-a-Service, Twilio → MQTT Gateway, Skillz, and the course website itself.

Code Coverage

Property-Based Testing Property-based testing generates input values with which to test your functions. The Hypothesis package implements property-based testing for Python. Fuzz testing and property-based testing are closely related.

Unit Testing, Continued More unit tests for Bear. Some things that typically happen to your code when you add unit tests.

How to Test Exceptions Unit-testing code that raises exceptions. Refactoring unit tests. Adding tests before you extend and refactor code.

Code Coverage, Revisited How I was wrong about logger.info. Excluding the “main” runner from coverage reports.

Logging Use Python’s logger to print information. Print lots of information. How to view logs on Heroku. Kinds of debugging. The similarities and differences between local and server debugging.

Hide Files From Git With .gitignore Don’t ignore the .gitignore! Punishment: death by git merge conflict (and a messy repo).