Checkpoint

Checkpoint: The Pump Inspector

Every lighthouse has an oil pump with an alarm. When the oil level drops below 20, check_pump sends a "refill" message to the keeper and returns True. Otherwise it sends nothing and returns False.

The Guild wants a proper unittest suite for it, so nobody can break the alarm by accident. Use what you learned in this chapter: setUp, a Mock in place of the real messenger, and tests on both sides of the boundary.

Assignment

Finish TestPump. Don't change check_pump.

  1. In setUp, store a fresh Mock() in self.keeper.
  2. test_low_oil_sends_refill: at level 19, check that check_pump returns True and that self.keeper.send was called once with "refill".
  3. test_enough_oil_is_quiet: at level 20, check that it returns False and that self.keeper.send was never called (use assert_not_called()).