Use device_registry fixture in webostv tests (#119269)

pull/106947/head^2
epenet 2024-06-10 09:40:54 +02:00 committed by GitHub
parent 1ebc1685f7
commit a5cde4b32b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 14 deletions

View File

@ -11,7 +11,7 @@ from homeassistant.components.webostv import DOMAIN, device_trigger
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.device_registry import async_get as get_dev_reg
from homeassistant.helpers import device_registry as dr
from homeassistant.setup import async_setup_component
from . import setup_webostv
@ -20,12 +20,13 @@ from .const import ENTITY_ID, FAKE_UUID
from tests.common import MockConfigEntry, async_get_device_automations
async def test_get_triggers(hass: HomeAssistant, client) -> None:
async def test_get_triggers(
hass: HomeAssistant, device_registry: dr.DeviceRegistry, client
) -> None:
"""Test we get the expected triggers."""
await setup_webostv(hass)
device_reg = get_dev_reg(hass)
device = device_reg.async_get_device(identifiers={(DOMAIN, FAKE_UUID)})
device = device_registry.async_get_device(identifiers={(DOMAIN, FAKE_UUID)})
turn_on_trigger = {
"platform": "device",
@ -42,13 +43,15 @@ async def test_get_triggers(hass: HomeAssistant, client) -> None:
async def test_if_fires_on_turn_on_request(
hass: HomeAssistant, calls: list[ServiceCall], client
hass: HomeAssistant,
calls: list[ServiceCall],
device_registry: dr.DeviceRegistry,
client,
) -> None:
"""Test for turn_on and turn_off triggers firing."""
await setup_webostv(hass)
device_reg = get_dev_reg(hass)
device = device_reg.async_get_device(identifiers={(DOMAIN, FAKE_UUID)})
device = device_registry.async_get_device(identifiers={(DOMAIN, FAKE_UUID)})
assert await async_setup_component(
hass,
@ -101,7 +104,9 @@ async def test_if_fires_on_turn_on_request(
assert calls[1].data["id"] == 0
async def test_failure_scenarios(hass: HomeAssistant, client) -> None:
async def test_failure_scenarios(
hass: HomeAssistant, device_registry: dr.DeviceRegistry, client
) -> None:
"""Test failure scenarios."""
await setup_webostv(hass)
@ -125,9 +130,8 @@ async def test_failure_scenarios(hass: HomeAssistant, client) -> None:
entry = MockConfigEntry(domain="fake", state=ConfigEntryState.LOADED, data={})
entry.add_to_hass(hass)
device_reg = get_dev_reg(hass)
device = device_reg.async_get_or_create(
device = device_registry.async_get_or_create(
config_entry_id=entry.entry_id, identifiers={("fake", "fake")}
)

View File

@ -9,7 +9,7 @@ from homeassistant.components.webostv import DOMAIN
from homeassistant.const import SERVICE_RELOAD
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.device_registry import async_get as get_dev_reg
from homeassistant.helpers import device_registry as dr
from homeassistant.setup import async_setup_component
from . import setup_webostv
@ -19,13 +19,15 @@ from tests.common import MockEntity, MockEntityPlatform
async def test_webostv_turn_on_trigger_device_id(
hass: HomeAssistant, calls: list[ServiceCall], client
hass: HomeAssistant,
calls: list[ServiceCall],
device_registry: dr.DeviceRegistry,
client,
) -> None:
"""Test for turn_on triggers by device_id firing."""
await setup_webostv(hass)
device_reg = get_dev_reg(hass)
device = device_reg.async_get_device(identifiers={(DOMAIN, FAKE_UUID)})
device = device_registry.async_get_device(identifiers={(DOMAIN, FAKE_UUID)})
assert await async_setup_component(
hass,