mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Migrate HomeWizard to new entity naming style (#74958)
This commit is contained in:
@@ -39,7 +39,7 @@ async def test_switch_entity_not_loaded_when_not_available(
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state_power_on = hass.states.get("sensor.product_name_aabbccddeeff_switch")
|
||||
state_power_on = hass.states.get("sensor.product_name_aabbccddeeff")
|
||||
state_switch_lock = hass.states.get("sensor.product_name_aabbccddeeff_switch_lock")
|
||||
|
||||
assert state_power_on is None
|
||||
@@ -67,10 +67,8 @@ async def test_switch_loads_entities(hass, mock_config_entry_data, mock_config_e
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
state_power_on = hass.states.get("switch.product_name_aabbccddeeff_switch")
|
||||
entry_power_on = entity_registry.async_get(
|
||||
"switch.product_name_aabbccddeeff_switch"
|
||||
)
|
||||
state_power_on = hass.states.get("switch.product_name_aabbccddeeff")
|
||||
entry_power_on = entity_registry.async_get("switch.product_name_aabbccddeeff")
|
||||
assert state_power_on
|
||||
assert entry_power_on
|
||||
assert entry_power_on.unique_id == "aabbccddeeff_power_on"
|
||||
@@ -78,7 +76,7 @@ async def test_switch_loads_entities(hass, mock_config_entry_data, mock_config_e
|
||||
assert state_power_on.state == STATE_OFF
|
||||
assert (
|
||||
state_power_on.attributes.get(ATTR_FRIENDLY_NAME)
|
||||
== "Product Name (aabbccddeeff) Switch"
|
||||
== "Product Name (aabbccddeeff)"
|
||||
)
|
||||
assert state_power_on.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_OUTLET
|
||||
assert ATTR_ICON not in state_power_on.attributes
|
||||
@@ -95,7 +93,7 @@ async def test_switch_loads_entities(hass, mock_config_entry_data, mock_config_e
|
||||
assert state_switch_lock.state == STATE_OFF
|
||||
assert (
|
||||
state_switch_lock.attributes.get(ATTR_FRIENDLY_NAME)
|
||||
== "Product Name (aabbccddeeff) Switch Lock"
|
||||
== "Product Name (aabbccddeeff) Switch lock"
|
||||
)
|
||||
assert state_switch_lock.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_SWITCH
|
||||
assert ATTR_ICON not in state_switch_lock.attributes
|
||||
@@ -127,38 +125,30 @@ async def test_switch_power_on_off(hass, mock_config_entry_data, mock_config_ent
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert (
|
||||
hass.states.get("switch.product_name_aabbccddeeff_switch").state
|
||||
== STATE_OFF
|
||||
)
|
||||
assert hass.states.get("switch.product_name_aabbccddeeff").state == STATE_OFF
|
||||
|
||||
# Turn power_on on
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{"entity_id": "switch.product_name_aabbccddeeff_switch"},
|
||||
{"entity_id": "switch.product_name_aabbccddeeff"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert len(api.state_set.mock_calls) == 1
|
||||
assert (
|
||||
hass.states.get("switch.product_name_aabbccddeeff_switch").state == STATE_ON
|
||||
)
|
||||
assert hass.states.get("switch.product_name_aabbccddeeff").state == STATE_ON
|
||||
|
||||
# Turn power_on off
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{"entity_id": "switch.product_name_aabbccddeeff_switch"},
|
||||
{"entity_id": "switch.product_name_aabbccddeeff"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
hass.states.get("switch.product_name_aabbccddeeff_switch").state
|
||||
== STATE_OFF
|
||||
)
|
||||
assert hass.states.get("switch.product_name_aabbccddeeff").state == STATE_OFF
|
||||
assert len(api.state_set.mock_calls) == 2
|
||||
|
||||
|
||||
@@ -254,9 +244,7 @@ async def test_switch_lock_sets_power_on_unavailable(
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert (
|
||||
hass.states.get("switch.product_name_aabbccddeeff_switch").state == STATE_ON
|
||||
)
|
||||
assert hass.states.get("switch.product_name_aabbccddeeff").state == STATE_ON
|
||||
assert (
|
||||
hass.states.get("switch.product_name_aabbccddeeff_switch_lock").state
|
||||
== STATE_OFF
|
||||
@@ -273,7 +261,7 @@ async def test_switch_lock_sets_power_on_unavailable(
|
||||
await hass.async_block_till_done()
|
||||
assert len(api.state_set.mock_calls) == 1
|
||||
assert (
|
||||
hass.states.get("switch.product_name_aabbccddeeff_switch").state
|
||||
hass.states.get("switch.product_name_aabbccddeeff").state
|
||||
== STATE_UNAVAILABLE
|
||||
)
|
||||
assert (
|
||||
@@ -290,9 +278,7 @@ async def test_switch_lock_sets_power_on_unavailable(
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
hass.states.get("switch.product_name_aabbccddeeff_switch").state == STATE_ON
|
||||
)
|
||||
assert hass.states.get("switch.product_name_aabbccddeeff").state == STATE_ON
|
||||
assert (
|
||||
hass.states.get("switch.product_name_aabbccddeeff_switch_lock").state
|
||||
== STATE_OFF
|
||||
|
||||
Reference in New Issue
Block a user