Assignment #06: exceptions and testing

Assignment #06: exceptions and testing#

This week you have learned two important new concepts: unit testing and exceptions handling. In today’s assignment we will revisit old code in order to properly test it and make it more robust.

Exercise #06-01: refactor and test old code#

  • Write a test suite for the following past exercises: “#02: cryptography”, “#03: automated data download”, and “#05-05: wind statistics” (one test_*.py file per module). The test suite must contain unit tests for each function you programmed. While doing so, you might find it very useful to refactor your code following the good practices: write small functions with a task clearly defined, which you can test for. If you can’t test it, the function is possibly not written the right way: either too broad, or not useful enough.

  • Apply the exception handling methods learned in the Exceptions chapter to the download function(s) of exercise #03. Add a test to your test suite to verify that exceptions are raised when an invalid tile is requested for download.