Fix homekit_controller tests to avoid global aid generation (#119852)

This commit is contained in:
J. Nick Koston 2024-07-17 19:10:02 -05:00 committed by GitHub
parent 454ca0ce95
commit e2276458ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 792 additions and 344 deletions

View file

@ -1,5 +1,7 @@
"""Test homekit_controller stateless triggers."""
from collections.abc import Callable
from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import ServicesTypes
@ -65,9 +67,13 @@ def create_doorbell(accessory):
battery.add_char(CharacteristicsTypes.BATTERY_LEVEL)
async def test_remote(hass: HomeAssistant, entity_registry: er.EntityRegistry) -> None:
async def test_remote(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
get_next_aid: Callable[[], int],
) -> None:
"""Test that remote is supported."""
helper = await setup_test_component(hass, create_remote)
helper = await setup_test_component(hass, get_next_aid(), create_remote)
entities = [
("event.testdevice_button_1", "Button 1"),
@ -108,9 +114,13 @@ async def test_remote(hass: HomeAssistant, entity_registry: er.EntityRegistry) -
assert state.attributes["event_type"] == "long_press"
async def test_button(hass: HomeAssistant, entity_registry: er.EntityRegistry) -> None:
async def test_button(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
get_next_aid: Callable[[], int],
) -> None:
"""Test that a button is correctly enumerated."""
helper = await setup_test_component(hass, create_button)
helper = await setup_test_component(hass, get_next_aid(), create_button)
entity_id = "event.testdevice_button_1"
button = entity_registry.async_get(entity_id)
@ -145,10 +155,12 @@ async def test_button(hass: HomeAssistant, entity_registry: er.EntityRegistry) -
async def test_doorbell(
hass: HomeAssistant, entity_registry: er.EntityRegistry
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
get_next_aid: Callable[[], int],
) -> None:
"""Test that doorbell service is handled."""
helper = await setup_test_component(hass, create_doorbell)
helper = await setup_test_component(hass, get_next_aid(), create_doorbell)
entity_id = "event.testdevice_doorbell"
doorbell = entity_registry.async_get(entity_id)