1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Yoda assertion style removed is (#48142)

This commit is contained in:
Franck Nijhof
2021-03-20 13:55:10 +01:00
committed by GitHub
parent 365e8a74ee
commit 5a2b5fe7c5
75 changed files with 1137 additions and 1148 deletions

View File

@@ -116,13 +116,13 @@ async def test_heater_input_boolean(hass, setup_comp_1):
)
await hass.async_block_till_done()
assert STATE_OFF == hass.states.get(heater_switch).state
assert hass.states.get(heater_switch).state == STATE_OFF
_setup_sensor(hass, 18)
await hass.async_block_till_done()
await common.async_set_temperature(hass, 23)
assert STATE_ON == hass.states.get(heater_switch).state
assert hass.states.get(heater_switch).state == STATE_ON
async def test_heater_switch(hass, setup_comp_1):
@@ -151,13 +151,13 @@ async def test_heater_switch(hass, setup_comp_1):
)
await hass.async_block_till_done()
assert STATE_OFF == hass.states.get(heater_switch).state
assert hass.states.get(heater_switch).state == STATE_OFF
_setup_sensor(hass, 18)
await common.async_set_temperature(hass, 23)
await hass.async_block_till_done()
assert STATE_ON == hass.states.get(heater_switch).state
assert hass.states.get(heater_switch).state == STATE_ON
async def test_unique_id(hass, setup_comp_1):
@@ -234,7 +234,7 @@ async def test_setup_defaults_to_unknown(hass):
},
)
await hass.async_block_till_done()
assert HVAC_MODE_OFF == hass.states.get(ENTITY).state
assert hass.states.get(ENTITY).state == HVAC_MODE_OFF
async def test_setup_gets_current_temp_from_sensor(hass):
@@ -264,27 +264,27 @@ async def test_setup_gets_current_temp_from_sensor(hass):
async def test_default_setup_params(hass, setup_comp_2):
"""Test the setup with default parameters."""
state = hass.states.get(ENTITY)
assert 7 == state.attributes.get("min_temp")
assert 35 == state.attributes.get("max_temp")
assert 7 == state.attributes.get("temperature")
assert state.attributes.get("min_temp") == 7
assert state.attributes.get("max_temp") == 35
assert state.attributes.get("temperature") == 7
async def test_get_hvac_modes(hass, setup_comp_2):
"""Test that the operation list returns the correct modes."""
state = hass.states.get(ENTITY)
modes = state.attributes.get("hvac_modes")
assert [HVAC_MODE_HEAT, HVAC_MODE_OFF] == modes
assert modes == [HVAC_MODE_HEAT, HVAC_MODE_OFF]
async def test_set_target_temp(hass, setup_comp_2):
"""Test the setting of the target temperature."""
await common.async_set_temperature(hass, 30)
state = hass.states.get(ENTITY)
assert 30.0 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 30.0
with pytest.raises(vol.Invalid):
await common.async_set_temperature(hass, None)
state = hass.states.get(ENTITY)
assert 30.0 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 30.0
async def test_set_away_mode(hass, setup_comp_2):
@@ -292,7 +292,7 @@ async def test_set_away_mode(hass, setup_comp_2):
await common.async_set_temperature(hass, 23)
await common.async_set_preset_mode(hass, PRESET_AWAY)
state = hass.states.get(ENTITY)
assert 16 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 16
async def test_set_away_mode_and_restore_prev_temp(hass, setup_comp_2):
@@ -303,10 +303,10 @@ async def test_set_away_mode_and_restore_prev_temp(hass, setup_comp_2):
await common.async_set_temperature(hass, 23)
await common.async_set_preset_mode(hass, PRESET_AWAY)
state = hass.states.get(ENTITY)
assert 16 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 16
await common.async_set_preset_mode(hass, PRESET_NONE)
state = hass.states.get(ENTITY)
assert 23 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 23
async def test_set_away_mode_twice_and_restore_prev_temp(hass, setup_comp_2):
@@ -318,10 +318,10 @@ async def test_set_away_mode_twice_and_restore_prev_temp(hass, setup_comp_2):
await common.async_set_preset_mode(hass, PRESET_AWAY)
await common.async_set_preset_mode(hass, PRESET_AWAY)
state = hass.states.get(ENTITY)
assert 16 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 16
await common.async_set_preset_mode(hass, PRESET_NONE)
state = hass.states.get(ENTITY)
assert 23 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 23
async def test_sensor_bad_value(hass, setup_comp_2):
@@ -382,11 +382,11 @@ async def test_set_target_temp_heater_on(hass, setup_comp_2):
_setup_sensor(hass, 25)
await hass.async_block_till_done()
await common.async_set_temperature(hass, 30)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_set_target_temp_heater_off(hass, setup_comp_2):
@@ -395,11 +395,11 @@ async def test_set_target_temp_heater_off(hass, setup_comp_2):
_setup_sensor(hass, 30)
await hass.async_block_till_done()
await common.async_set_temperature(hass, 25)
assert 2 == len(calls)
assert len(calls) == 2
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_heater_on_within_tolerance(hass, setup_comp_2):
@@ -408,7 +408,7 @@ async def test_temp_change_heater_on_within_tolerance(hass, setup_comp_2):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 29)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_heater_on_outside_tolerance(hass, setup_comp_2):
@@ -417,11 +417,11 @@ async def test_temp_change_heater_on_outside_tolerance(hass, setup_comp_2):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 27)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_heater_off_within_tolerance(hass, setup_comp_2):
@@ -430,7 +430,7 @@ async def test_temp_change_heater_off_within_tolerance(hass, setup_comp_2):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 33)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_heater_off_outside_tolerance(hass, setup_comp_2):
@@ -439,11 +439,11 @@ async def test_temp_change_heater_off_outside_tolerance(hass, setup_comp_2):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 35)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_running_when_hvac_mode_is_off(hass, setup_comp_2):
@@ -451,11 +451,11 @@ async def test_running_when_hvac_mode_is_off(hass, setup_comp_2):
calls = _setup_switch(hass, True)
await common.async_set_temperature(hass, 30)
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_no_state_change_when_hvac_mode_off(hass, setup_comp_2):
@@ -465,7 +465,7 @@ async def test_no_state_change_when_hvac_mode_off(hass, setup_comp_2):
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_hvac_mode_heat(hass, setup_comp_2):
@@ -479,11 +479,11 @@ async def test_hvac_mode_heat(hass, setup_comp_2):
await hass.async_block_till_done()
calls = _setup_switch(hass, False)
await common.async_set_hvac_mode(hass, HVAC_MODE_HEAT)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
def _setup_switch(hass, is_on):
@@ -532,11 +532,11 @@ async def test_set_target_temp_ac_off(hass, setup_comp_3):
_setup_sensor(hass, 25)
await hass.async_block_till_done()
await common.async_set_temperature(hass, 30)
assert 2 == len(calls)
assert len(calls) == 2
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_turn_away_mode_on_cooling(hass, setup_comp_3):
@@ -547,7 +547,7 @@ async def test_turn_away_mode_on_cooling(hass, setup_comp_3):
await common.async_set_temperature(hass, 19)
await common.async_set_preset_mode(hass, PRESET_AWAY)
state = hass.states.get(ENTITY)
assert 30 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 30
async def test_hvac_mode_cool(hass, setup_comp_3):
@@ -561,11 +561,11 @@ async def test_hvac_mode_cool(hass, setup_comp_3):
await hass.async_block_till_done()
calls = _setup_switch(hass, False)
await common.async_set_hvac_mode(hass, HVAC_MODE_COOL)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_set_target_temp_ac_on(hass, setup_comp_3):
@@ -574,11 +574,11 @@ async def test_set_target_temp_ac_on(hass, setup_comp_3):
_setup_sensor(hass, 30)
await hass.async_block_till_done()
await common.async_set_temperature(hass, 25)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_ac_off_within_tolerance(hass, setup_comp_3):
@@ -587,7 +587,7 @@ async def test_temp_change_ac_off_within_tolerance(hass, setup_comp_3):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 29.8)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_set_temp_change_ac_off_outside_tolerance(hass, setup_comp_3):
@@ -596,11 +596,11 @@ async def test_set_temp_change_ac_off_outside_tolerance(hass, setup_comp_3):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 27)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_ac_on_within_tolerance(hass, setup_comp_3):
@@ -609,7 +609,7 @@ async def test_temp_change_ac_on_within_tolerance(hass, setup_comp_3):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 25.2)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_ac_on_outside_tolerance(hass, setup_comp_3):
@@ -618,11 +618,11 @@ async def test_temp_change_ac_on_outside_tolerance(hass, setup_comp_3):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_running_when_operating_mode_is_off_2(hass, setup_comp_3):
@@ -630,11 +630,11 @@ async def test_running_when_operating_mode_is_off_2(hass, setup_comp_3):
calls = _setup_switch(hass, True)
await common.async_set_temperature(hass, 30)
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_no_state_change_when_operation_mode_off_2(hass, setup_comp_3):
@@ -644,7 +644,7 @@ async def test_no_state_change_when_operation_mode_off_2(hass, setup_comp_3):
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
_setup_sensor(hass, 35)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
@pytest.fixture
@@ -677,7 +677,7 @@ async def test_temp_change_ac_trigger_on_not_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_ac_trigger_on_long_enough(hass, setup_comp_4):
@@ -692,11 +692,11 @@ async def test_temp_change_ac_trigger_on_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_ac_trigger_off_not_long_enough(hass, setup_comp_4):
@@ -705,7 +705,7 @@ async def test_temp_change_ac_trigger_off_not_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_ac_trigger_off_long_enough(hass, setup_comp_4):
@@ -720,11 +720,11 @@ async def test_temp_change_ac_trigger_off_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_ac_trigger_off_not_long_enough(hass, setup_comp_4):
@@ -733,13 +733,13 @@ async def test_mode_change_ac_trigger_off_not_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_ac_trigger_on_not_long_enough(hass, setup_comp_4):
@@ -748,13 +748,13 @@ async def test_mode_change_ac_trigger_on_not_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_HEAT)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
@pytest.fixture
@@ -787,7 +787,7 @@ async def test_temp_change_ac_trigger_on_not_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_ac_trigger_on_long_enough_2(hass, setup_comp_5):
@@ -802,11 +802,11 @@ async def test_temp_change_ac_trigger_on_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_ac_trigger_off_not_long_enough_2(hass, setup_comp_5):
@@ -815,7 +815,7 @@ async def test_temp_change_ac_trigger_off_not_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_ac_trigger_off_long_enough_2(hass, setup_comp_5):
@@ -830,11 +830,11 @@ async def test_temp_change_ac_trigger_off_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_ac_trigger_off_not_long_enough_2(hass, setup_comp_5):
@@ -843,13 +843,13 @@ async def test_mode_change_ac_trigger_off_not_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_ac_trigger_on_not_long_enough_2(hass, setup_comp_5):
@@ -858,13 +858,13 @@ async def test_mode_change_ac_trigger_on_not_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_HEAT)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
@pytest.fixture
@@ -896,7 +896,7 @@ async def test_temp_change_heater_trigger_off_not_long_enough(hass, setup_comp_6
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_heater_trigger_on_not_long_enough(hass, setup_comp_6):
@@ -905,7 +905,7 @@ async def test_temp_change_heater_trigger_on_not_long_enough(hass, setup_comp_6)
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_heater_trigger_on_long_enough(hass, setup_comp_6):
@@ -920,11 +920,11 @@ async def test_temp_change_heater_trigger_on_long_enough(hass, setup_comp_6):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_heater_trigger_off_long_enough(hass, setup_comp_6):
@@ -939,11 +939,11 @@ async def test_temp_change_heater_trigger_off_long_enough(hass, setup_comp_6):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_heater_trigger_off_not_long_enough(hass, setup_comp_6):
@@ -952,13 +952,13 @@ async def test_mode_change_heater_trigger_off_not_long_enough(hass, setup_comp_6
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_heater_trigger_on_not_long_enough(hass, setup_comp_6):
@@ -967,13 +967,13 @@ async def test_mode_change_heater_trigger_on_not_long_enough(hass, setup_comp_6)
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_HEAT)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
@pytest.fixture
@@ -1013,17 +1013,17 @@ async def test_temp_change_ac_trigger_on_long_enough_3(hass, setup_comp_7):
test_time = datetime.datetime.now(pytz.UTC)
async_fire_time_changed(hass, test_time)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=5))
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=10))
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_ac_trigger_off_long_enough_3(hass, setup_comp_7):
@@ -1036,17 +1036,17 @@ async def test_temp_change_ac_trigger_off_long_enough_3(hass, setup_comp_7):
test_time = datetime.datetime.now(pytz.UTC)
async_fire_time_changed(hass, test_time)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=5))
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=10))
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
@pytest.fixture
@@ -1084,17 +1084,17 @@ async def test_temp_change_heater_trigger_on_long_enough_2(hass, setup_comp_8):
test_time = datetime.datetime.now(pytz.UTC)
async_fire_time_changed(hass, test_time)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=5))
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=10))
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_heater_trigger_off_long_enough_2(hass, setup_comp_8):
@@ -1107,17 +1107,17 @@ async def test_temp_change_heater_trigger_off_long_enough_2(hass, setup_comp_8):
test_time = datetime.datetime.now(pytz.UTC)
async_fire_time_changed(hass, test_time)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=5))
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=10))
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
@pytest.fixture
@@ -1149,7 +1149,7 @@ async def test_precision(hass, setup_comp_9):
"""Test that setting precision to tenths works as intended."""
await common.async_set_temperature(hass, 23.27)
state = hass.states.get(ENTITY)
assert 23.3 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 23.3
async def test_custom_setup_params(hass):
@@ -1350,14 +1350,14 @@ async def test_restore_state_uncoherence_case(hass):
await hass.async_block_till_done()
state = hass.states.get(ENTITY)
assert 20 == state.attributes[ATTR_TEMPERATURE]
assert HVAC_MODE_OFF == state.state
assert 0 == len(calls)
assert state.attributes[ATTR_TEMPERATURE] == 20
assert state.state == HVAC_MODE_OFF
assert len(calls) == 0
calls = _setup_switch(hass, False)
await hass.async_block_till_done()
state = hass.states.get(ENTITY)
assert HVAC_MODE_OFF == state.state
assert state.state == HVAC_MODE_OFF
async def _setup_climate(hass):