Paul's Python CoursePPC

Project 9 of 9, for Paul

Acceptance Test Suite

On the roof, by the clock face, the clock's controller gets its first tests. Then the clock runs.

About an hour and a half, in 7 steps.

Sign up free to open itLog in

Act 9 needs a free account, so your work is saved as you go. Act 1 is open to everyone.

The brief

  • PaulGood, everyone's here. Let's sort out the clock.
  • PaulIt's said 3:14 since before I had the keys, and tonight it's going to run.
  • NeilThe gears are fine, Aaesha and I checked every one of them in the Engine Room.
  • AaeshaIt's the controller that's the problem. It learned the clock from old logs and nobody ever tested it.
  • PaulSo we test it first, and then we start it.

The clock's controller decides, from the readings outside, whether to light the clock face, switch on the fog lamp and heat the hands so ice can't stop them. It learned this from three winters of logs and has never had a single test.

Write the tests, in test_clock.py: test functions that check decide against the clockmaker's rules, written down here for the first time, and that catch what the controller never learned. Your tests should pass on a controller that follows the rules, and fail on this one.

What it prints
lamp: lit when it's dark, or when visibility is under 2000 m
fog lamp: on when visibility is under 500 m, whatever the ice
heater: on with 4.4 mm of ice on the hands or more, or 4.0 mm or more in wind force 8 or above

What's in it

  1. Why the clock stopped
  2. Ask it something hard
  3. Tests from the rules
  4. Tests for the clock
  5. Off, or on
  6. Ship it