Fix freedompro tests (#61012)

This commit is contained in:
Marc Mueller 2021-12-12 23:09:45 +01:00 committed by GitHub
parent 6e7de8f85d
commit cbe58913ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 212 additions and 78 deletions

View file

@ -25,7 +25,7 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.util.dt import utcnow
from tests.common import async_fire_time_changed
from tests.components.freedompro.const import DEVICES_STATE
from tests.components.freedompro.conftest import get_states_response_for_uid
uid = "3WRRJR6RCZQZSND8VP0YTO3YXCSOFPKBMW8T51TU-LQ*TWMYQKL3UVED4HSIIB9GXJWJZBQCXG-9VE-N2IUAIWI"
@ -64,14 +64,12 @@ async def test_climate_get_state(hass, init_integration):
assert entry
assert entry.unique_id == uid
get_states_response = list(DEVICES_STATE)
for state_response in get_states_response:
if state_response["uid"] == uid:
state_response["state"]["currentTemperature"] = 20
state_response["state"]["targetTemperature"] = 21
states_response = get_states_response_for_uid(uid)
states_response[0]["state"]["currentTemperature"] = 20
states_response[0]["state"]["targetTemperature"] = 21
with patch(
"homeassistant.components.freedompro.get_states",
return_value=get_states_response,
return_value=states_response,
):
async_fire_time_changed(hass, utcnow() + timedelta(hours=2))
await hass.async_block_till_done()
@ -172,7 +170,16 @@ async def test_climate_set_temperature(hass, init_integration):
ANY, ANY, ANY, '{"heatingCoolingState": 0, "targetTemperature": 25.0}'
)
await hass.async_block_till_done()
states_response = get_states_response_for_uid(uid)
states_response[0]["state"]["currentTemperature"] = 20
states_response[0]["state"]["targetTemperature"] = 21
with patch(
"homeassistant.components.freedompro.get_states",
return_value=states_response,
):
async_fire_time_changed(hass, utcnow() + timedelta(hours=2))
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert state.attributes[ATTR_TEMPERATURE] == 21