예제 #1
0
 def test_pump_triggered_if_low_moisture(self):
     manager = pump.PumpManager(pump=self.mock_pump,
                                pump_scheduler=self.mock_pump_scheduler,
                                moisture_threshold=300,
                                pump_amount=200,
                                timer=self.mock_timer)
     self.mock_pump_scheduler.is_running_pump_allowed.return_value = True
     self.mock_timer.expired.return_value = False
     ml_pumped = manager.pump_if_needed(200)
     self.mock_pump.pump_water.assert_called_once_with(200)
     self.mock_timer.reset.assert_called_once()
     self.assertEqual(ml_pumped, 200)
예제 #2
0
 def test_pump_is_disabled_during_quiet_hours(self):
     manager = pump.PumpManager(pump=self.mock_pump,
                                pump_scheduler=self.mock_pump_scheduler,
                                moisture_threshold=300,
                                pump_amount=200,
                                timer=self.mock_timer)
     self.mock_pump_scheduler.is_running_pump_allowed.return_value = False
     self.mock_timer.expired.return_value = False
     ml_pumped = manager.pump_if_needed(200)
     self.assertFalse(self.mock_pump.pump_water.called)
     self.assertFalse(self.mock_timer.reset.called)
     self.assertEqual(ml_pumped, 0)
예제 #3
0
 def test_pump_not_triggered_if_moisture_is_high(self):
     manager = pump.PumpManager(pump=self.mock_pump,
                                pump_scheduler=self.mock_pump_scheduler,
                                moisture_threshold=300,
                                pump_amount=200,
                                timer=self.mock_timer)
     self.mock_pump_scheduler.is_running_pump_allowed.return_value = True
     self.mock_timer.expired.return_value = False
     ml_pumped = manager.pump_if_needed(650)
     # Pump should not run if soil moisture is above threshold.
     self.assertFalse(self.mock_pump.pump_water.called)
     self.assertFalse(self.mock_timer.reset.called)
     self.assertEqual(ml_pumped, 0)