Exemple #1
0
    def test_pump_doesnt_start_with_error(self):
        moisture_sensor = MockSensor(1)
        error_contr = mock_error_controle.MockErrorContr(True)

        water_schedule = pump_schedule.Watering_Schedule(
            moisture_sensor, error_contr)
        with water_schedule as pump_sch:
            pump_sch._config.disable_reload = True
            enable_test_time_config(pump_sch._config)
            self.assertEqual(0, pump_sch.pump.pump.value)
            (pump_sch.
             enable_pump_until_moisture_sencor_is_saturated_for_duration())
Exemple #2
0
    def test_water_not_recived_by_sensor__timedout(self):

        moisture_sensor = MockSensor(10)

        start_moisture_level = moisture_sensor.get_moisture_a2d()
        error_contr = mock_error_controle.MockErrorContr()

        with pump_schedule.Watering_Schedule(moisture_sensor, error_contr) as pump_sch:
            pump_sch._config.disable_reload = True
            enable_test_time_config(pump_sch._config)
            pump_sch._config.data["water_detected_timeout"] = 0.1
            (pump_sch.
             enable_pump_until_moisture_sencor_is_saturated_for_duration())

        self.assertFalse(moisture_sensor.get_moisture_a2d()
                         > start_moisture_level)
Exemple #3
0
    def test_water_recived_by_sensor(self):

        moisture_sensor = MockSensor(1)

        start_moisture_level = moisture_sensor.get_moisture_a2d()
        error_contr = mock_error_controle.MockErrorContr()
        water_schedule = pump_schedule.Watering_Schedule(
            moisture_sensor, error_contr)

        with water_schedule as pump_sch:
            pump_sch._config.disable_reload = True
            enable_test_time_config(pump_sch._config)
            (pump_sch.
             enable_pump_until_moisture_sencor_is_saturated_for_duration())

        self.assertTrue(moisture_sensor.get_moisture_a2d()
                        > start_moisture_level)