Deduplicate OTBR test fixtures (#124293)

pull/119974/head^2
Erik Montnemery 2024-08-20 14:58:34 +02:00 committed by GitHub
parent 15976b8207
commit a1e3e7f24f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 30 deletions

View File

@ -72,7 +72,12 @@ def get_extended_address_fixture() -> Generator[AsyncMock]:
@pytest.fixture(name="otbr_config_entry_multipan")
async def otbr_config_entry_multipan_fixture(hass: HomeAssistant) -> None:
async def otbr_config_entry_multipan_fixture(
hass: HomeAssistant,
get_active_dataset_tlvs: AsyncMock,
get_border_agent_id: AsyncMock,
get_extended_address: AsyncMock,
) -> None:
"""Mock Open Thread Border Router config entry."""
config_entry = MockConfigEntry(
data=CONFIG_ENTRY_DATA_MULTIPAN,
@ -81,24 +86,16 @@ async def otbr_config_entry_multipan_fixture(hass: HomeAssistant) -> None:
title="Open Thread Border Router",
)
config_entry.add_to_hass(hass)
with (
patch(
"python_otbr_api.OTBR.get_active_dataset_tlvs", return_value=DATASET_CH16
),
patch(
"python_otbr_api.OTBR.get_border_agent_id",
return_value=TEST_BORDER_AGENT_ID,
),
patch(
"python_otbr_api.OTBR.get_extended_address",
return_value=TEST_BORDER_AGENT_EXTENDED_ADDRESS,
),
):
assert await hass.config_entries.async_setup(config_entry.entry_id)
assert await hass.config_entries.async_setup(config_entry.entry_id)
@pytest.fixture(name="otbr_config_entry_thread")
async def otbr_config_entry_thread_fixture(hass: HomeAssistant) -> None:
async def otbr_config_entry_thread_fixture(
hass: HomeAssistant,
get_active_dataset_tlvs: AsyncMock,
get_border_agent_id: AsyncMock,
get_extended_address: AsyncMock,
) -> None:
"""Mock Open Thread Border Router config entry."""
config_entry = MockConfigEntry(
data=CONFIG_ENTRY_DATA_THREAD,
@ -107,20 +104,7 @@ async def otbr_config_entry_thread_fixture(hass: HomeAssistant) -> None:
title="Open Thread Border Router",
)
config_entry.add_to_hass(hass)
with (
patch(
"python_otbr_api.OTBR.get_active_dataset_tlvs", return_value=DATASET_CH16
),
patch(
"python_otbr_api.OTBR.get_border_agent_id",
return_value=TEST_BORDER_AGENT_ID,
),
patch(
"python_otbr_api.OTBR.get_extended_address",
return_value=TEST_BORDER_AGENT_EXTENDED_ADDRESS,
),
):
assert await hass.config_entries.async_setup(config_entry.entry_id)
assert await hass.config_entries.async_setup(config_entry.entry_id)
@pytest.fixture(autouse=True)