mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Finish config flow in huawei_lte SSDP test (#147542)
This commit is contained in:
parent
0be0e22e76
commit
5129f89086
@ -330,24 +330,25 @@ async def test_ssdp(
|
|||||||
url = FIXTURE_USER_INPUT[CONF_URL][:-1] # strip trailing slash for appending port
|
url = FIXTURE_USER_INPUT[CONF_URL][:-1] # strip trailing slash for appending port
|
||||||
context = {"source": config_entries.SOURCE_SSDP}
|
context = {"source": config_entries.SOURCE_SSDP}
|
||||||
login_requests_mock.request(**requests_mock_request_kwargs)
|
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(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context=context,
|
context=context,
|
||||||
data=SsdpServiceInfo(
|
data=service_info,
|
||||||
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,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for k, v in expected_result.items():
|
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"] is not None
|
||||||
assert result["data_schema"]({})[CONF_URL] == url + "/"
|
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(
|
@pytest.mark.parametrize(
|
||||||
("login_response_text", "expected_result", "expected_entry_data"),
|
("login_response_text", "expected_result", "expected_entry_data"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user