Netgear test coverage (#72150)
This commit is contained in:
parent
cfe9ea033a
commit
f7b96c87d0
2 changed files with 32 additions and 5 deletions
|
@ -191,11 +191,6 @@ class NetgearFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
if errors:
|
||||
return await self._show_setup_form(user_input, errors)
|
||||
|
||||
# Check if already configured
|
||||
info = await self.hass.async_add_executor_job(api.get_info)
|
||||
await self.async_set_unique_id(info["SerialNumber"], raise_on_progress=False)
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
config_data = {
|
||||
CONF_USERNAME: username,
|
||||
CONF_PASSWORD: password,
|
||||
|
@ -204,6 +199,11 @@ class NetgearFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
CONF_SSL: api.ssl,
|
||||
}
|
||||
|
||||
# Check if already configured
|
||||
info = await self.hass.async_add_executor_job(api.get_info)
|
||||
await self.async_set_unique_id(info["SerialNumber"], raise_on_progress=False)
|
||||
self._abort_if_unique_id_configured(updates=config_data)
|
||||
|
||||
if info.get("ModelName") is not None and info.get("DeviceName") is not None:
|
||||
name = f"{info['ModelName']} - {info['DeviceName']}"
|
||||
else:
|
||||
|
|
|
@ -59,6 +59,7 @@ SSL = False
|
|||
USERNAME = "Home_Assistant"
|
||||
PASSWORD = "password"
|
||||
SSDP_URL = f"http://{HOST}:{PORT}/rootDesc.xml"
|
||||
SSDP_URLipv6 = f"http://[::ffff:a00:1]:{PORT}/rootDesc.xml"
|
||||
SSDP_URL_SLL = f"https://{HOST}:{PORT}/rootDesc.xml"
|
||||
|
||||
|
||||
|
@ -234,6 +235,32 @@ async def test_ssdp_already_configured(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_ssdp_ipv6(hass):
|
||||
"""Test ssdp abort when using a ipv6 address."""
|
||||
MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={CONF_PASSWORD: PASSWORD},
|
||||
unique_id=SERIAL,
|
||||
).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location=SSDP_URLipv6,
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_MODEL_NUMBER: "RBR20",
|
||||
ssdp.ATTR_UPNP_PRESENTATION_URL: URL,
|
||||
ssdp.ATTR_UPNP_SERIAL: SERIAL,
|
||||
},
|
||||
),
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "not_ipv4_address"
|
||||
|
||||
|
||||
async def test_ssdp(hass, service):
|
||||
"""Test ssdp step."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
|
Loading…
Add table
Reference in a new issue