Use unique_id in devolo Home Network tests (#133147)

This commit is contained in:
Guido Schmitz 2024-12-16 13:35:55 +01:00 committed by GitHub
parent 836fd94a56
commit cc27c95bad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 10 deletions

View File

@ -4,7 +4,7 @@ from homeassistant.components.devolo_home_network.const import DOMAIN
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD
from homeassistant.core import HomeAssistant
from .const import IP
from .const import DISCOVERY_INFO, IP
from tests.common import MockConfigEntry
@ -15,7 +15,12 @@ def configure_integration(hass: HomeAssistant) -> MockConfigEntry:
CONF_IP_ADDRESS: IP,
CONF_PASSWORD: "test",
}
entry = MockConfigEntry(domain=DOMAIN, data=config, entry_id="123456")
entry = MockConfigEntry(
domain=DOMAIN,
data=config,
entry_id="123456",
unique_id=DISCOVERY_INFO.properties["SN"],
)
entry.add_to_hass(hass)
return entry

View File

@ -35,7 +35,7 @@
'subentries': list([
]),
'title': 'Mock Title',
'unique_id': None,
'unique_id': '1234567890',
'version': 1,
}),
})

View File

@ -29,8 +29,6 @@ from .const import (
)
from .mock import MockDevice
from tests.common import MockConfigEntry
async def test_form(hass: HomeAssistant, info: dict[str, Any]) -> None:
"""Test we get the form."""
@ -125,6 +123,8 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
CONF_IP_ADDRESS: IP,
CONF_PASSWORD: "",
}
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["result"].unique_id == "1234567890"
async def test_abort_zeroconf_wrong_device(hass: HomeAssistant) -> None:
@ -141,11 +141,7 @@ async def test_abort_zeroconf_wrong_device(hass: HomeAssistant) -> None:
@pytest.mark.usefixtures("info")
async def test_abort_if_configured(hass: HomeAssistant) -> None:
"""Test we abort config flow if already configured."""
serial_number = DISCOVERY_INFO.properties["SN"]
entry = MockConfigEntry(
domain=DOMAIN, unique_id=serial_number, data={CONF_IP_ADDRESS: IP}
)
entry.add_to_hass(hass)
entry = configure_integration(hass)
# Abort on concurrent user flow
result = await hass.config_entries.flow.async_init(