Update f-g* tests to use entity & device registry fixtures (#103841)

This commit is contained in:
Jan-Philipp Benecke 2023-11-12 13:07:38 +01:00 committed by GitHub
parent b9bc6ca070
commit 04a497343d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 317 additions and 270 deletions

View file

@ -21,13 +21,16 @@ from tests.common import async_fire_time_changed
uid = "3WRRJR6RCZQZSND8VP0YTO3YXCSOFPKBMW8T51TU-LQ*ILYH1E3DWZOVMNEUIMDYMNLOW-LFRQFDPWWJOVHVDOS"
async def test_fan_get_state(hass: HomeAssistant, init_integration) -> None:
async def test_fan_get_state(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
device_registry: dr.DeviceRegistry,
init_integration,
) -> None:
"""Test states of the fan."""
init_integration
registry = er.async_get(hass)
registry_device = dr.async_get(hass)
device = registry_device.async_get_device(identifiers={("freedompro", uid)})
device = device_registry.async_get_device(identifiers={("freedompro", uid)})
assert device is not None
assert device.identifiers == {("freedompro", uid)}
assert device.manufacturer == "Freedompro"
@ -41,7 +44,7 @@ async def test_fan_get_state(hass: HomeAssistant, init_integration) -> None:
assert state.attributes[ATTR_PERCENTAGE] == 0
assert state.attributes.get("friendly_name") == "bedroom"
entry = registry.async_get(entity_id)
entry = entity_registry.async_get(entity_id)
assert entry
assert entry.unique_id == uid
@ -59,7 +62,7 @@ async def test_fan_get_state(hass: HomeAssistant, init_integration) -> None:
assert state
assert state.attributes.get("friendly_name") == "bedroom"
entry = registry.async_get(entity_id)
entry = entity_registry.async_get(entity_id)
assert entry
assert entry.unique_id == uid
@ -67,10 +70,11 @@ async def test_fan_get_state(hass: HomeAssistant, init_integration) -> None:
assert state.attributes[ATTR_PERCENTAGE] == 50
async def test_fan_set_off(hass: HomeAssistant, init_integration) -> None:
async def test_fan_set_off(
hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration
) -> None:
"""Test turn off the fan."""
init_integration
registry = er.async_get(hass)
entity_id = "fan.bedroom"
@ -91,7 +95,7 @@ async def test_fan_set_off(hass: HomeAssistant, init_integration) -> None:
assert state.attributes[ATTR_PERCENTAGE] == 50
assert state.attributes.get("friendly_name") == "bedroom"
entry = registry.async_get(entity_id)
entry = entity_registry.async_get(entity_id)
assert entry
assert entry.unique_id == uid
@ -120,10 +124,11 @@ async def test_fan_set_off(hass: HomeAssistant, init_integration) -> None:
assert state.state == STATE_OFF
async def test_fan_set_on(hass: HomeAssistant, init_integration) -> None:
async def test_fan_set_on(
hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration
) -> None:
"""Test turn on the fan."""
init_integration
registry = er.async_get(hass)
entity_id = "fan.bedroom"
state = hass.states.get(entity_id)
@ -132,7 +137,7 @@ async def test_fan_set_on(hass: HomeAssistant, init_integration) -> None:
assert state.attributes[ATTR_PERCENTAGE] == 0
assert state.attributes.get("friendly_name") == "bedroom"
entry = registry.async_get(entity_id)
entry = entity_registry.async_get(entity_id)
assert entry
assert entry.unique_id == uid
@ -160,10 +165,11 @@ async def test_fan_set_on(hass: HomeAssistant, init_integration) -> None:
assert state.state == STATE_ON
async def test_fan_set_percent(hass: HomeAssistant, init_integration) -> None:
async def test_fan_set_percent(
hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration
) -> None:
"""Test turn on the fan."""
init_integration
registry = er.async_get(hass)
entity_id = "fan.bedroom"
state = hass.states.get(entity_id)
@ -172,7 +178,7 @@ async def test_fan_set_percent(hass: HomeAssistant, init_integration) -> None:
assert state.attributes[ATTR_PERCENTAGE] == 0
assert state.attributes.get("friendly_name") == "bedroom"
entry = registry.async_get(entity_id)
entry = entity_registry.async_get(entity_id)
assert entry
assert entry.unique_id == uid