1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-13 17:44:45 +01:00

Add discovery mocks to tplink init tests (#164386)

This commit is contained in:
Franck Nijhof
2026-02-28 01:23:47 +01:00
committed by GitHub
parent 3fae15c430
commit 1be8b8e525
+17 -1
View File
@@ -545,7 +545,12 @@ async def test_unlink_devices(
}
assert device_entries[0].identifiers == set(test_identifiers)
with patch("homeassistant.components.tplink.CONF_CONFIG_ENTRY_MINOR_VERSION", 3):
with (
patch("homeassistant.components.tplink.CONF_CONFIG_ENTRY_MINOR_VERSION", 3),
_patch_discovery(),
_patch_single_discovery(),
_patch_connect(),
):
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
@@ -596,6 +601,8 @@ async def test_move_credentials_hash(
patch("homeassistant.components.tplink.Device.connect", new=_connect),
patch("homeassistant.components.tplink.PLATFORMS", []),
patch("homeassistant.components.tplink.CONF_CONFIG_ENTRY_MINOR_VERSION", 4),
_patch_discovery(),
_patch_single_discovery(),
):
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
@@ -640,6 +647,8 @@ async def test_move_credentials_hash_auth_error(
),
patch("homeassistant.components.tplink.PLATFORMS", []),
patch("homeassistant.components.tplink.CONF_CONFIG_ENTRY_MINOR_VERSION", 4),
_patch_discovery(),
_patch_single_discovery(),
):
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
@@ -682,6 +691,8 @@ async def test_move_credentials_hash_other_error(
),
patch("homeassistant.components.tplink.PLATFORMS", []),
patch("homeassistant.components.tplink.CONF_CONFIG_ENTRY_MINOR_VERSION", 4),
_patch_discovery(),
_patch_single_discovery(),
):
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
@@ -717,6 +728,8 @@ async def test_credentials_hash(
with (
patch("homeassistant.components.tplink.PLATFORMS", []),
patch("homeassistant.components.tplink.Device.connect", new=_connect),
_patch_discovery(),
_patch_single_discovery(),
):
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
@@ -753,6 +766,8 @@ async def test_credentials_hash_auth_error(
"homeassistant.components.tplink.Device.connect",
side_effect=AuthenticationError,
) as connect_mock,
_patch_discovery(),
_patch_single_discovery(),
):
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
@@ -782,6 +797,7 @@ async def test_credentials_hash_auth_error(
async def test_migrate_remove_device_config(
hass: HomeAssistant,
mock_connect: AsyncMock,
mock_discovery: AsyncMock,
caplog: pytest.LogCaptureFixture,
device_config: DeviceConfig,
expected_entry_data: dict[str, Any],