|
@@ -1,9 +1,11 @@
|
|
|
"""Tests for the Quto 03 Sprinkler."""
|
|
"""Tests for the Quto 03 Sprinkler."""
|
|
|
|
|
|
|
|
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
|
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
|
|
|
|
+from homeassistant.components.valve import ValveDeviceClass, ValveEntityFeature
|
|
|
from homeassistant.const import PERCENTAGE, UnitOfTime
|
|
from homeassistant.const import PERCENTAGE, UnitOfTime
|
|
|
|
|
|
|
|
from ..const import QOTO_SPRINKLER_PAYLOAD
|
|
from ..const import QOTO_SPRINKLER_PAYLOAD
|
|
|
|
|
+from ..helpers import assert_device_properties_set
|
|
|
from ..mixins.binary_sensor import BasicBinarySensorTests
|
|
from ..mixins.binary_sensor import BasicBinarySensorTests
|
|
|
from ..mixins.number import MultiNumberTests
|
|
from ..mixins.number import MultiNumberTests
|
|
|
from ..mixins.sensor import MultiSensorTests
|
|
from ..mixins.sensor import MultiSensorTests
|
|
@@ -26,6 +28,7 @@ class TestQotoSprinkler(
|
|
|
|
|
|
|
|
def setUp(self):
|
|
def setUp(self):
|
|
|
self.setUpForConfig("qoto_03_sprinkler.yaml", QOTO_SPRINKLER_PAYLOAD)
|
|
self.setUpForConfig("qoto_03_sprinkler.yaml", QOTO_SPRINKLER_PAYLOAD)
|
|
|
|
|
+ self.subject = self.entities.get("valve_water")
|
|
|
self.setUpBasicBinarySensor(
|
|
self.setUpBasicBinarySensor(
|
|
|
ERROR_DPS,
|
|
ERROR_DPS,
|
|
|
self.entities.get("binary_sensor_problem"),
|
|
self.entities.get("binary_sensor_problem"),
|
|
@@ -66,9 +69,58 @@ class TestQotoSprinkler(
|
|
|
)
|
|
)
|
|
|
self.mark_secondary(
|
|
self.mark_secondary(
|
|
|
[
|
|
[
|
|
|
|
|
+ "number",
|
|
|
"binary_sensor_problem",
|
|
"binary_sensor_problem",
|
|
|
"number_timer",
|
|
"number_timer",
|
|
|
"sensor_open",
|
|
"sensor_open",
|
|
|
"sensor_timer",
|
|
"sensor_timer",
|
|
|
]
|
|
]
|
|
|
)
|
|
)
|
|
|
|
|
+
|
|
|
|
|
+ def test_device_class_is_water(self):
|
|
|
|
|
+ self.assertEqual(self.subject.device_class, ValveDeviceClass.WATER)
|
|
|
|
|
+
|
|
|
|
|
+ def test_supported_features(self):
|
|
|
|
|
+ self.assertEqual(
|
|
|
|
|
+ self.subject.supported_features,
|
|
|
|
|
+ ValveEntityFeature.OPEN
|
|
|
|
|
+ | ValveEntityFeature.CLOSE
|
|
|
|
|
+ | ValveEntityFeature.SET_POSITION,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ def test_is_closed(self):
|
|
|
|
|
+ self.dps[TARGET_DPS] = 100
|
|
|
|
|
+ self.assertFalse(self.subject.is_closed)
|
|
|
|
|
+ self.dps[TARGET_DPS] = 50
|
|
|
|
|
+ self.assertFalse(self.subject.is_closed)
|
|
|
|
|
+ self.dps[TARGET_DPS] = 0
|
|
|
|
|
+ self.assertTrue(self.subject.is_closed)
|
|
|
|
|
+
|
|
|
|
|
+ def test_current_position(self):
|
|
|
|
|
+ self.dps[TARGET_DPS] = 100
|
|
|
|
|
+ self.assertEqual(self.subject.current_position, 100)
|
|
|
|
|
+ self.dps[TARGET_DPS] = 50
|
|
|
|
|
+ self.assertEqual(self.subject.current_position, 50)
|
|
|
|
|
+ self.dps[TARGET_DPS] = 0
|
|
|
|
|
+ self.assertEqual(self.subject.current_position, 0)
|
|
|
|
|
+
|
|
|
|
|
+ async def test_open_valve(self):
|
|
|
|
|
+ async with assert_device_properties_set(
|
|
|
|
|
+ self.subject._device,
|
|
|
|
|
+ {TARGET_DPS: 100},
|
|
|
|
|
+ ):
|
|
|
|
|
+ await self.subject.async_open_valve()
|
|
|
|
|
+
|
|
|
|
|
+ async def test_close_valve(self):
|
|
|
|
|
+ async with assert_device_properties_set(
|
|
|
|
|
+ self.subject._device,
|
|
|
|
|
+ {TARGET_DPS: 0},
|
|
|
|
|
+ ):
|
|
|
|
|
+ await self.subject.async_close_valve()
|
|
|
|
|
+
|
|
|
|
|
+ async def test_set_valve_position(self):
|
|
|
|
|
+ async with assert_device_properties_set(
|
|
|
|
|
+ self.subject._device,
|
|
|
|
|
+ {TARGET_DPS: 50},
|
|
|
|
|
+ ):
|
|
|
|
|
+ await self.subject.async_set_valve_position(50)
|