Finish config flow in huawei_lte SSDP test (#147542)

This commit is contained in:
Ville Skyttä 2025-06-27 17:00:01 +00:00 committed by GitHub
parent 0be0e22e76
commit 5129f89086
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -330,24 +330,25 @@ async def test_ssdp(
url = FIXTURE_USER_INPUT[CONF_URL][:-1] # strip trailing slash for appending port
context = {"source": config_entries.SOURCE_SSDP}
login_requests_mock.request(**requests_mock_request_kwargs)
service_info = SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="upnp:rootdevice",
ssdp_location=f"{url}:60957/rootDesc.xml",
upnp={
ATTR_UPNP_DEVICE_TYPE: "urn:schemas-upnp-org:device:InternetGatewayDevice:1",
ATTR_UPNP_MANUFACTURER: "Huawei",
ATTR_UPNP_MANUFACTURER_URL: "http://www.huawei.com/",
ATTR_UPNP_MODEL_NAME: "Huawei router",
ATTR_UPNP_MODEL_NUMBER: "12345678",
ATTR_UPNP_PRESENTATION_URL: url,
ATTR_UPNP_UDN: "uuid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
**upnp_data,
},
)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context=context,
data=SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="upnp:rootdevice",
ssdp_location=f"{url}:60957/rootDesc.xml",
upnp={
ATTR_UPNP_DEVICE_TYPE: "urn:schemas-upnp-org:device:InternetGatewayDevice:1",
ATTR_UPNP_MANUFACTURER: "Huawei",
ATTR_UPNP_MANUFACTURER_URL: "http://www.huawei.com/",
ATTR_UPNP_MODEL_NAME: "Huawei router",
ATTR_UPNP_MODEL_NUMBER: "12345678",
ATTR_UPNP_PRESENTATION_URL: url,
ATTR_UPNP_UDN: "uuid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
**upnp_data,
},
),
data=service_info,
)
for k, v in expected_result.items():
@ -356,6 +357,23 @@ async def test_ssdp(
assert result["data_schema"] is not None
assert result["data_schema"]({})[CONF_URL] == url + "/"
if result["type"] == FlowResultType.ABORT:
return
login_requests_mock.request(
ANY,
f"{FIXTURE_USER_INPUT[CONF_URL]}api/user/login",
text="<response>OK</response>",
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={},
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["title"] == service_info.upnp[ATTR_UPNP_MODEL_NAME]
@pytest.mark.parametrize(
("login_response_text", "expected_result", "expected_entry_data"),