Add Vallox cell state sensor tests (#67069)

This commit is contained in:
Sebastian Lövdahl 2022-03-30 06:07:09 +03:00 committed by GitHub
parent f4c443ac86
commit ced68c1b80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 85 additions and 2 deletions

View File

@ -1322,10 +1322,8 @@ omit =
homeassistant/components/upc_connect/*
homeassistant/components/uscis/sensor.py
homeassistant/components/vallox/__init__.py
homeassistant/components/vallox/const.py
homeassistant/components/vallox/fan.py
homeassistant/components/vallox/sensor.py
homeassistant/components/vallox/binary_sensor.py
homeassistant/components/vasttrafik/sensor.py
homeassistant/components/velbus/__init__.py
homeassistant/components/velbus/binary_sensor.py

View File

@ -158,3 +158,88 @@ async def test_remaining_time_for_filter_in_the_past(
mocked_filter_end_date,
_now_at_13(),
)
async def test_cell_state_sensor_heat_recovery(
mock_entry: MockConfigEntry, hass: HomeAssistant
):
"""Test cell state sensor in heat recovery state."""
# Arrange
metrics = {"A_CYC_CELL_STATE": 0}
# Act
with patch_metrics(metrics=metrics):
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
# Assert
sensor = hass.states.get("sensor.vallox_cell_state")
assert sensor.state == "Heat Recovery"
async def test_cell_state_sensor_cool_recovery(
mock_entry: MockConfigEntry, hass: HomeAssistant
):
"""Test cell state sensor in cool recovery state."""
# Arrange
metrics = {"A_CYC_CELL_STATE": 1}
# Act
with patch_metrics(metrics=metrics):
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
# Assert
sensor = hass.states.get("sensor.vallox_cell_state")
assert sensor.state == "Cool Recovery"
async def test_cell_state_sensor_bypass(
mock_entry: MockConfigEntry, hass: HomeAssistant
):
"""Test cell state sensor in bypass state."""
# Arrange
metrics = {"A_CYC_CELL_STATE": 2}
# Act
with patch_metrics(metrics=metrics):
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
# Assert
sensor = hass.states.get("sensor.vallox_cell_state")
assert sensor.state == "Bypass"
async def test_cell_state_sensor_defrosting(
mock_entry: MockConfigEntry, hass: HomeAssistant
):
"""Test cell state sensor in defrosting state."""
# Arrange
metrics = {"A_CYC_CELL_STATE": 3}
# Act
with patch_metrics(metrics=metrics):
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
# Assert
sensor = hass.states.get("sensor.vallox_cell_state")
assert sensor.state == "Defrosting"
async def test_cell_state_sensor_unknown_state(
mock_entry: MockConfigEntry, hass: HomeAssistant
):
"""Test cell state sensor in unknown state."""
# Arrange
metrics = {"A_CYC_CELL_STATE": 4}
# Act
with patch_metrics(metrics=metrics):
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
# Assert
sensor = hass.states.get("sensor.vallox_cell_state")
assert sensor.state == "unknown"