Use registry fixtures in tests (s) (#118295)

This commit is contained in:
epenet
2024-05-28 15:41:03 +02:00
committed by GitHub
parent 90500c4b97
commit e58d060f82
56 changed files with 377 additions and 318 deletions

View File

@ -888,7 +888,9 @@ async def test_extraction_functions(
assert script.blueprint_in_script(hass, "script.test3") is None
async def test_config_basic(hass: HomeAssistant) -> None:
async def test_config_basic(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test passing info in config."""
assert await async_setup_component(
hass,
@ -908,8 +910,7 @@ async def test_config_basic(hass: HomeAssistant) -> None:
assert test_script.name == "Script Name"
assert test_script.attributes["icon"] == "mdi:party"
registry = er.async_get(hass)
entry = registry.async_get("script.test_script")
entry = entity_registry.async_get("script.test_script")
assert entry
assert entry.unique_id == "test_script"
@ -1503,11 +1504,12 @@ async def test_websocket_config(
assert msg["error"]["code"] == "not_found"
async def test_script_service_changed_entity_id(hass: HomeAssistant) -> None:
async def test_script_service_changed_entity_id(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test the script service works for scripts with overridden entity_id."""
entity_reg = er.async_get(hass)
entry = entity_reg.async_get_or_create("script", "script", "test")
entry = entity_reg.async_update_entity(
entry = entity_registry.async_get_or_create("script", "script", "test")
entry = entity_registry.async_update_entity(
entry.entity_id, new_entity_id="script.custom_entity_id"
)
assert entry.entity_id == "script.custom_entity_id"
@ -1545,7 +1547,7 @@ async def test_script_service_changed_entity_id(hass: HomeAssistant) -> None:
assert calls[0].data["entity_id"] == "script.custom_entity_id"
# Change entity while the script entity is loaded, and make sure the service still works
entry = entity_reg.async_update_entity(
entry = entity_registry.async_update_entity(
entry.entity_id, new_entity_id="script.custom_entity_id_2"
)
assert entry.entity_id == "script.custom_entity_id_2"