Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions tests/components/huawei_lte/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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"),
Expand Down