diff --git a/tests/components/huawei_lte/test_config_flow.py b/tests/components/huawei_lte/test_config_flow.py index f75b0e7f2b0..5e018e73f2a 100644 --- a/tests/components/huawei_lte/test_config_flow.py +++ b/tests/components/huawei_lte/test_config_flow.py @@ -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="OK", + ) + 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"),