Update h* tests to use entity & device registry fixtures (#103866)

* Update h* tests to use entity & device registry fixtures

* Add missed lines
This commit is contained in:
Jan-Philipp Benecke 2023-11-12 19:52:32 +01:00 committed by GitHub
parent 3a531f5698
commit eda475fe25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 330 additions and 240 deletions

View file

@ -64,7 +64,9 @@ def create_doorbell(accessory):
battery.add_char(CharacteristicsTypes.BATTERY_LEVEL)
async def test_remote(hass: HomeAssistant, utcnow) -> None:
async def test_remote(
hass: HomeAssistant, entity_registry: er.EntityRegistry, utcnow
) -> None:
"""Test that remote is supported."""
helper = await setup_test_component(hass, create_remote)
@ -75,8 +77,6 @@ async def test_remote(hass: HomeAssistant, utcnow) -> None:
("event.testdevice_button_4", "Button 4"),
]
entity_registry = er.async_get(hass)
for entity_id, service in entities:
button = entity_registry.async_get(entity_id)
@ -109,12 +109,13 @@ async def test_remote(hass: HomeAssistant, utcnow) -> None:
assert state.attributes["event_type"] == "long_press"
async def test_button(hass: HomeAssistant, utcnow) -> None:
async def test_button(
hass: HomeAssistant, entity_registry: er.EntityRegistry, utcnow
) -> None:
"""Test that a button is correctly enumerated."""
helper = await setup_test_component(hass, create_button)
entity_id = "event.testdevice_button_1"
entity_registry = er.async_get(hass)
button = entity_registry.async_get(entity_id)
assert button.original_device_class == EventDeviceClass.BUTTON
@ -146,12 +147,13 @@ async def test_button(hass: HomeAssistant, utcnow) -> None:
assert state.attributes["event_type"] == "long_press"
async def test_doorbell(hass: HomeAssistant, utcnow) -> None:
async def test_doorbell(
hass: HomeAssistant, entity_registry: er.EntityRegistry, utcnow
) -> None:
"""Test that doorbell service is handled."""
helper = await setup_test_component(hass, create_doorbell)
entity_id = "event.testdevice_doorbell"
entity_registry = er.async_get(hass)
doorbell = entity_registry.async_get(entity_id)
assert doorbell.original_device_class == EventDeviceClass.DOORBELL