mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Fix sensibo test coverage to 100% (#132202)
This commit is contained in:
parent
f0c07d68c5
commit
5a1d5802c4
@ -22,7 +22,7 @@ from homeassistant.const import (
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util.unit_conversion import TemperatureConverter
|
||||
@ -108,7 +108,7 @@ AC_STATE_TO_DATA = {
|
||||
}
|
||||
|
||||
|
||||
def _find_valid_target_temp(target: int, valid_targets: list[int]) -> int:
|
||||
def _find_valid_target_temp(target: float, valid_targets: list[int]) -> int:
|
||||
if target <= valid_targets[0]:
|
||||
return valid_targets[0]
|
||||
if target >= valid_targets[-1]:
|
||||
@ -320,12 +320,7 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
||||
translation_key="no_target_temperature_in_features",
|
||||
)
|
||||
|
||||
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="no_target_temperature",
|
||||
)
|
||||
|
||||
temperature: float = kwargs[ATTR_TEMPERATURE]
|
||||
if temperature == self.target_temperature:
|
||||
return
|
||||
|
||||
|
@ -500,9 +500,6 @@
|
||||
"no_target_temperature_in_features": {
|
||||
"message": "Current mode doesn't support setting target temperature"
|
||||
},
|
||||
"no_target_temperature": {
|
||||
"message": "No target temperature provided"
|
||||
},
|
||||
"no_fan_level_in_features": {
|
||||
"message": "Current mode doesn't support setting fan level"
|
||||
},
|
||||
|
@ -347,6 +347,17 @@ async def test_climate_temperatures(
|
||||
state2 = hass.states.get("climate.hallway")
|
||||
assert state2.attributes["temperature"] == 20
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.sensibo.coordinator.SensiboClient.async_set_ac_state_property",
|
||||
) as mock_call:
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: state1.entity_id, ATTR_TEMPERATURE: 20},
|
||||
blocking=True,
|
||||
)
|
||||
assert not mock_call.called
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.sensibo.coordinator.SensiboClient.async_get_devices_data",
|
||||
|
Loading…
x
Reference in New Issue
Block a user