Disable expensive pskc computation in all otbr tests (#124292)
* Disable expensive pskc computation in all otbr tests * Update tests and fixtures which patched compute_pskc
This commit is contained in:
parent
b1d9e5580c
commit
15976b8207
2 changed files with 21 additions and 8 deletions
|
@ -20,6 +20,23 @@ from . import (
|
|||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture(name="enable_compute_pskc")
|
||||
def enable_compute_pskc_fixture() -> Any:
|
||||
"""Allow controlling if compute_pskc should be enabled."""
|
||||
return False
|
||||
|
||||
|
||||
@pytest.fixture(name="compute_pskc", autouse=True)
|
||||
def compute_pskc_fixture(enable_compute_pskc: bool) -> Any:
|
||||
"""Patch homeassistant.components.otbr.util.compute_pskc."""
|
||||
compute_pskc = otbr.util.compute_pskc if enable_compute_pskc else None
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.otbr.util.compute_pskc", side_effect=compute_pskc
|
||||
) as compute_pskc_mock:
|
||||
yield compute_pskc_mock
|
||||
|
||||
|
||||
@pytest.fixture(name="dataset")
|
||||
def dataset_fixture() -> Any:
|
||||
"""Return the discovery info from the supervisor."""
|
||||
|
@ -76,8 +93,7 @@ async def otbr_config_entry_multipan_fixture(hass: HomeAssistant) -> None:
|
|||
"python_otbr_api.OTBR.get_extended_address",
|
||||
return_value=TEST_BORDER_AGENT_EXTENDED_ADDRESS,
|
||||
),
|
||||
patch("homeassistant.components.otbr.util.compute_pskc"),
|
||||
): # Patch to speed up tests
|
||||
):
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
||||
|
||||
|
@ -103,8 +119,7 @@ async def otbr_config_entry_thread_fixture(hass: HomeAssistant) -> None:
|
|||
"python_otbr_api.OTBR.get_extended_address",
|
||||
return_value=TEST_BORDER_AGENT_EXTENDED_ADDRESS,
|
||||
),
|
||||
patch("homeassistant.components.otbr.util.compute_pskc"),
|
||||
): # Patch to speed up tests
|
||||
):
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
||||
|
||||
|
|
|
@ -198,6 +198,7 @@ async def test_import_share_radio_no_channel_collision(
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("enable_compute_pskc", [True])
|
||||
@pytest.mark.parametrize(
|
||||
"dataset", [DATASET_INSECURE_NW_KEY, DATASET_INSECURE_PASSPHRASE]
|
||||
)
|
||||
|
@ -333,8 +334,5 @@ async def test_remove_extra_entries(
|
|||
config_entry1.add_to_hass(hass)
|
||||
config_entry2.add_to_hass(hass)
|
||||
assert len(hass.config_entries.async_entries(otbr.DOMAIN)) == 2
|
||||
with (
|
||||
patch("homeassistant.components.otbr.util.compute_pskc"),
|
||||
): # Patch to speed up tests
|
||||
assert await async_setup_component(hass, otbr.DOMAIN, {})
|
||||
assert await async_setup_component(hass, otbr.DOMAIN, {})
|
||||
assert len(hass.config_entries.async_entries(otbr.DOMAIN)) == 1
|
||||
|
|
Loading…
Add table
Reference in a new issue