Skip to content

Commit 5129f89

Browse files
authored
Finish config flow in huawei_lte SSDP test (#147542)
1 parent 0be0e22 commit 5129f89

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

tests/components/huawei_lte/test_config_flow.py

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -330,24 +330,25 @@ async def test_ssdp(
330330
url = FIXTURE_USER_INPUT[CONF_URL][:-1] # strip trailing slash for appending port
331331
context = {"source": config_entries.SOURCE_SSDP}
332332
login_requests_mock.request(**requests_mock_request_kwargs)
333+
service_info = SsdpServiceInfo(
334+
ssdp_usn="mock_usn",
335+
ssdp_st="upnp:rootdevice",
336+
ssdp_location=f"{url}:60957/rootDesc.xml",
337+
upnp={
338+
ATTR_UPNP_DEVICE_TYPE: "urn:schemas-upnp-org:device:InternetGatewayDevice:1",
339+
ATTR_UPNP_MANUFACTURER: "Huawei",
340+
ATTR_UPNP_MANUFACTURER_URL: "http://www.huawei.com/",
341+
ATTR_UPNP_MODEL_NAME: "Huawei router",
342+
ATTR_UPNP_MODEL_NUMBER: "12345678",
343+
ATTR_UPNP_PRESENTATION_URL: url,
344+
ATTR_UPNP_UDN: "uuid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
345+
**upnp_data,
346+
},
347+
)
333348
result = await hass.config_entries.flow.async_init(
334349
DOMAIN,
335350
context=context,
336-
data=SsdpServiceInfo(
337-
ssdp_usn="mock_usn",
338-
ssdp_st="upnp:rootdevice",
339-
ssdp_location=f"{url}:60957/rootDesc.xml",
340-
upnp={
341-
ATTR_UPNP_DEVICE_TYPE: "urn:schemas-upnp-org:device:InternetGatewayDevice:1",
342-
ATTR_UPNP_MANUFACTURER: "Huawei",
343-
ATTR_UPNP_MANUFACTURER_URL: "http://www.huawei.com/",
344-
ATTR_UPNP_MODEL_NAME: "Huawei router",
345-
ATTR_UPNP_MODEL_NUMBER: "12345678",
346-
ATTR_UPNP_PRESENTATION_URL: url,
347-
ATTR_UPNP_UDN: "uuid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
348-
**upnp_data,
349-
},
350-
),
351+
data=service_info,
351352
)
352353

353354
for k, v in expected_result.items():
@@ -356,6 +357,23 @@ async def test_ssdp(
356357
assert result["data_schema"] is not None
357358
assert result["data_schema"]({})[CONF_URL] == url + "/"
358359

360+
if result["type"] == FlowResultType.ABORT:
361+
return
362+
363+
login_requests_mock.request(
364+
ANY,
365+
f"{FIXTURE_USER_INPUT[CONF_URL]}api/user/login",
366+
text="<response>OK</response>",
367+
)
368+
result = await hass.config_entries.flow.async_configure(
369+
result["flow_id"],
370+
user_input={},
371+
)
372+
await hass.async_block_till_done()
373+
374+
assert result["type"] == FlowResultType.CREATE_ENTRY
375+
assert result["title"] == service_info.upnp[ATTR_UPNP_MODEL_NAME]
376+
359377

360378
@pytest.mark.parametrize(
361379
("login_response_text", "expected_result", "expected_entry_data"),

0 commit comments

Comments
 (0)