From 23a8b29bfe8b3aadc6624ff88d5de150196986ac Mon Sep 17 00:00:00 2001 From: G Johansson Date: Tue, 30 Apr 2024 21:31:52 +0200 Subject: [PATCH] Bring sensibo to full coverage (again) (#116469) --- tests/components/sensibo/test_climate.py | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/components/sensibo/test_climate.py b/tests/components/sensibo/test_climate.py index 061e31f9771..55d404b8331 100644 --- a/tests/components/sensibo/test_climate.py +++ b/tests/components/sensibo/test_climate.py @@ -121,6 +121,32 @@ async def test_climate_fan( state1 = hass.states.get("climate.hallway") assert state1.attributes["fan_mode"] == "high" + monkeypatch.setattr( + get_data.parsed["ABC999111"], + "fan_modes", + ["quiet", "low", "medium", "not_in_ha"], + ) + monkeypatch.setattr( + get_data.parsed["ABC999111"], + "fan_modes_translated", + { + "low": "low", + "medium": "medium", + "quiet": "quiet", + "not_in_ha": "not_in_ha", + }, + ) + with pytest.raises( + HomeAssistantError, + match="Climate fan mode not_in_ha is not supported by the integration", + ): + await hass.services.async_call( + CLIMATE_DOMAIN, + SERVICE_SET_FAN_MODE, + {ATTR_ENTITY_ID: state1.entity_id, ATTR_FAN_MODE: "not_in_ha"}, + blocking=True, + ) + with ( patch( "homeassistant.components.sensibo.coordinator.SensiboClient.async_get_devices_data", @@ -194,6 +220,42 @@ async def test_climate_swing( state1 = hass.states.get("climate.hallway") assert state1.attributes["swing_mode"] == "stopped" + monkeypatch.setattr( + get_data.parsed["ABC999111"], + "swing_modes", + ["stopped", "fixedtop", "fixedmiddletop", "not_in_ha"], + ) + monkeypatch.setattr( + get_data.parsed["ABC999111"], + "swing_modes_translated", + { + "fixedmiddletop": "fixedMiddleTop", + "fixedtop": "fixedTop", + "stopped": "stopped", + "not_in_ha": "not_in_ha", + }, + ) + with patch( + "homeassistant.components.sensibo.coordinator.SensiboClient.async_get_devices_data", + return_value=get_data, + ): + async_fire_time_changed( + hass, + dt_util.utcnow() + timedelta(minutes=5), + ) + await hass.async_block_till_done() + + with pytest.raises( + HomeAssistantError, + match="Climate swing mode not_in_ha is not supported by the integration", + ): + await hass.services.async_call( + CLIMATE_DOMAIN, + SERVICE_SET_SWING_MODE, + {ATTR_ENTITY_ID: state1.entity_id, ATTR_SWING_MODE: "not_in_ha"}, + blocking=True, + ) + with ( patch( "homeassistant.components.sensibo.coordinator.SensiboClient.async_get_devices_data",