def test_if_device_is_disabled_it_stops_after_routine(self): self._burnerProcess.Enabled = False self._burnerController.reset_mock() self._burnerController.tick.return_value = True self._burnerProcess._execute() self.assertEqual(self._burnerController.method_calls, [call.tick(), call.disable(), call.light_sensor()])
def test_if_device_is_enabled_should_run_correct_routines(self): self._burnerProcess.ScrewSec = 1 self._burnerProcess.DelaySec = 2 self._burnerProcess.Enabled = True # On first tick screw and fan should go on. self._burnerController.tick.return_value = False self._burnerProcess._execute() self._burnerController.assert_has_calls([call.tick(), call.start_cycle(1, 2), call.light_sensor()]) # Second tick. Screw stops now. self._burnerController.reset_mock() self._burnerController.tick.return_value = True # Now screw is stopped. self._burnerProcess._execute() self._burnerController.assert_has_calls([call.tick()]) # Third tick, everything keeps going. self._burnerController.reset_mock() self._burnerController.tick.return_value = True self._burnerProcess._execute() self._burnerController.assert_has_calls([call.tick()]) # Fourth tick. Screw should start again because delay is over. self._burnerController.reset_mock() self._burnerController.tick.return_value = False # Now screw is stopped. self._burnerProcess._execute() self._burnerController.assert_has_calls([call.tick(), call.start_cycle(1, 2), call.light_sensor()])