From 31364f7a1c827ad84a33104ebae7ef2df2ddaefc Mon Sep 17 00:00:00 2001 From: Erwin Douna Date: Fri, 9 Oct 2026 12:23:00 +0200 Subject: [PATCH] Assert the unique ID in config flow tests (batch 8) (#185283) --- tests/components/tractive/test_config_flow.py | 2 +- tests/components/twinkly/test_config_flow.py | 2 +- .../components/ukraine_alarm/test_config_flow.py | 4 ++-- .../components/unifi_access/test_config_flow.py | 2 +- .../components/unifiprotect/test_config_flow.py | 2 +- tests/components/upb/test_config_flow.py | 4 ++-- tests/components/upcloud/test_config_flow.py | 2 +- tests/components/upnp/test_config_flow.py | 10 +++++----- tests/components/uptime_kuma/test_config_flow.py | 2 +- tests/components/v2c/test_config_flow.py | 2 +- tests/components/verisure/test_config_flow.py | 4 ++-- tests/components/vicare/test_config_flow.py | 3 ++- .../test_config_flow.py | 4 ++-- tests/components/vistapool/test_config_flow.py | 6 +++--- tests/components/vlc_telnet/test_config_flow.py | 2 +- tests/components/volumio/test_config_flow.py | 2 +- tests/components/volvo/test_config_flow.py | 2 +- tests/components/watttime/test_config_flow.py | 4 ++-- tests/components/webmin/test_config_flow.py | 16 ++++++++++++---- tests/components/wilight/test_config_flow.py | 2 +- tests/components/withings/test_config_flow.py | 2 +- tests/components/wmspro/test_config_flow.py | 2 +- .../components/xiaomi_aqara/test_config_flow.py | 10 +++++----- tests/components/xiaomi_ble/test_config_flow.py | 2 +- tests/components/xiaomi_miio/test_config_flow.py | 8 ++++---- .../yale_smart_alarm/test_config_flow.py | 2 +- tests/components/yalexs_ble/test_config_flow.py | 4 ++-- .../yamaha_musiccast/test_config_flow.py | 6 +++--- tests/components/yardian/test_config_flow.py | 2 +- tests/components/zimi/test_config_flow.py | 2 +- tests/components/zwave_me/test_config_flow.py | 4 ++-- 31 files changed, 65 insertions(+), 56 deletions(-) diff --git a/tests/components/tractive/test_config_flow.py b/tests/components/tractive/test_config_flow.py index 195573a4ae81..579b3677968a 100644 --- a/tests/components/tractive/test_config_flow.py +++ b/tests/components/tractive/test_config_flow.py @@ -41,10 +41,10 @@ async def test_form(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "test-email@example.com" assert result2["data"] == USER_INPUT + assert result2["result"].unique_id == "user_id" assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/twinkly/test_config_flow.py b/tests/components/twinkly/test_config_flow.py index 921811ced112..5b6473af64c2 100644 --- a/tests/components/twinkly/test_config_flow.py +++ b/tests/components/twinkly/test_config_flow.py @@ -184,8 +184,8 @@ async def test_user_flow_works_discovery(hass: HomeAssistant) -> None: result["flow_id"], {CONF_HOST: "10.0.0.131"}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY + assert result["result"].unique_id == TEST_MAC # Verify the discovery flow was aborted assert not hass.config_entries.flow.async_progress(DOMAIN) diff --git a/tests/components/ukraine_alarm/test_config_flow.py b/tests/components/ukraine_alarm/test_config_flow.py index 768225febfcd..cf670703bd9d 100644 --- a/tests/components/ukraine_alarm/test_config_flow.py +++ b/tests/components/ukraine_alarm/test_config_flow.py @@ -58,13 +58,13 @@ async def test_state_district(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result4["type"] is FlowResultType.CREATE_ENTRY assert result4["title"] == "District 2.2" assert result4["data"] == { "region": "2.2", "name": result4["title"], } + assert result4["result"].unique_id == "2.2" assert len(mock_setup_entry.mock_calls) == 1 @@ -108,13 +108,13 @@ async def test_state_district_community(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result5["type"] is FlowResultType.CREATE_ENTRY assert result5["title"] == "Community 3.2.1" assert result5["data"] == { "region": "3.2.1", "name": result5["title"], } + assert result5["result"].unique_id == "3.2.1" assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/unifi_access/test_config_flow.py b/tests/components/unifi_access/test_config_flow.py index 4eaf58263128..62d41f3eb5e7 100644 --- a/tests/components/unifi_access/test_config_flow.py +++ b/tests/components/unifi_access/test_config_flow.py @@ -600,7 +600,6 @@ async def test_discovery_confirm_success( }, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "UniFi Access" assert result["data"] == { @@ -608,6 +607,7 @@ async def test_discovery_confirm_success( CONF_API_TOKEN: MOCK_API_TOKEN, CONF_VERIFY_SSL: False, } + assert result["result"].unique_id == "AABBCCDDEEFF" @pytest.mark.usefixtures("mock_setup_entry") diff --git a/tests/components/unifiprotect/test_config_flow.py b/tests/components/unifiprotect/test_config_flow.py index d50f63b43240..385e92d8d925 100644 --- a/tests/components/unifiprotect/test_config_flow.py +++ b/tests/components/unifiprotect/test_config_flow.py @@ -2151,10 +2151,10 @@ async def test_port_int_conversion( ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"][CONF_PORT] == 8443 assert isinstance(result["data"][CONF_PORT], int) + assert result["result"].unique_id == nvr.mac async def _start_api_key_flow(hass: HomeAssistant) -> ConfigFlowResult: diff --git a/tests/components/upb/test_config_flow.py b/tests/components/upb/test_config_flow.py index 6b99eff65065..d378b87d0211 100644 --- a/tests/components/upb/test_config_flow.py +++ b/tests/components/upb/test_config_flow.py @@ -77,25 +77,25 @@ async def test_full_upb_flow_with_serial_port(hass: HomeAssistant) -> None: assert flow["type"] is FlowResultType.FORM assert flow["errors"] == {} - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "UPB" assert result["data"] == { "device": "/dev/ttyS0", "file_path": "upb.upe", } + assert result["result"].unique_id == "42" assert len(mock_setup_entry.mock_calls) == 1 async def test_form_user_with_tcp_upb(hass: HomeAssistant) -> None: """Test we can setup a TCP upb.""" result = await valid_flow(hass, device="socket://1.2.3.4:2101") - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"] == { "device": "socket://1.2.3.4:2101", "file_path": "upb.upe", } + assert result["result"].unique_id == "42" await hass.async_block_till_done() diff --git a/tests/components/upcloud/test_config_flow.py b/tests/components/upcloud/test_config_flow.py index 2d36ed068806..97b9044b9c02 100644 --- a/tests/components/upcloud/test_config_flow.py +++ b/tests/components/upcloud/test_config_flow.py @@ -99,10 +99,10 @@ async def test_success( result["flow_id"], user_input=FIXTURE_USER_INPUT ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"][CONF_USERNAME] == FIXTURE_USER_INPUT[CONF_USERNAME] assert result["data"][CONF_PASSWORD] == FIXTURE_USER_INPUT[CONF_PASSWORD] + assert result["result"].unique_id == FIXTURE_USER_INPUT[CONF_USERNAME] async def test_already_configured( diff --git a/tests/components/upnp/test_config_flow.py b/tests/components/upnp/test_config_flow.py index bc470d546a79..ea8a91f0c671 100644 --- a/tests/components/upnp/test_config_flow.py +++ b/tests/components/upnp/test_config_flow.py @@ -61,7 +61,6 @@ async def test_flow_ssdp(hass: HomeAssistant) -> None: result["flow_id"], user_input={}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_FRIENDLY_NAME assert result["data"] == { @@ -72,6 +71,7 @@ async def test_flow_ssdp(hass: HomeAssistant) -> None: CONFIG_ENTRY_MAC_ADDRESS: TEST_MAC_ADDRESS, CONFIG_ENTRY_HOST: TEST_HOST, } + assert result["result"].unique_id == TEST_USN @pytest.mark.usefixtures( @@ -96,7 +96,6 @@ async def test_flow_ssdp_ignore(hass: HomeAssistant) -> None: context={"source": config_entries.SOURCE_IGNORE}, data={"unique_id": TEST_USN, "title": TEST_FRIENDLY_NAME}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_FRIENDLY_NAME assert result["data"] == { @@ -107,6 +106,7 @@ async def test_flow_ssdp_ignore(hass: HomeAssistant) -> None: CONFIG_ENTRY_MAC_ADDRESS: TEST_MAC_ADDRESS, CONFIG_ENTRY_HOST: TEST_HOST, } + assert result["result"].unique_id == TEST_USN async def test_flow_ssdp_incomplete_discovery(hass: HomeAssistant) -> None: @@ -172,7 +172,6 @@ async def test_flow_ssdp_no_mac_address(hass: HomeAssistant) -> None: result["flow_id"], user_input={}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_FRIENDLY_NAME assert result["data"] == { @@ -183,6 +182,7 @@ async def test_flow_ssdp_no_mac_address(hass: HomeAssistant) -> None: CONFIG_ENTRY_MAC_ADDRESS: None, CONFIG_ENTRY_HOST: TEST_HOST, } + assert result["result"].unique_id == TEST_USN @pytest.mark.usefixtures("mock_mac_address_from_host") @@ -421,7 +421,6 @@ async def test_flow_user(hass: HomeAssistant) -> None: result["flow_id"], user_input={"unique_id": TEST_USN}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_FRIENDLY_NAME assert result["data"] == { @@ -432,6 +431,7 @@ async def test_flow_user(hass: HomeAssistant) -> None: CONFIG_ENTRY_MAC_ADDRESS: TEST_MAC_ADDRESS, CONFIG_ENTRY_HOST: TEST_HOST, } + assert result["result"].unique_id == TEST_USN @pytest.mark.usefixtures( @@ -472,7 +472,6 @@ async def test_flow_ssdp_with_mismatched_udn(hass: HomeAssistant) -> None: result["flow_id"], user_input={}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_FRIENDLY_NAME assert result["data"] == { @@ -483,6 +482,7 @@ async def test_flow_ssdp_with_mismatched_udn(hass: HomeAssistant) -> None: CONFIG_ENTRY_MAC_ADDRESS: TEST_MAC_ADDRESS, CONFIG_ENTRY_HOST: TEST_HOST, } + assert result["result"].unique_id == TEST_USN async def test_options_flow( diff --git a/tests/components/uptime_kuma/test_config_flow.py b/tests/components/uptime_kuma/test_config_flow.py index 3eaac34cb41b..5915710e589f 100644 --- a/tests/components/uptime_kuma/test_config_flow.py +++ b/tests/components/uptime_kuma/test_config_flow.py @@ -349,7 +349,6 @@ async def test_hassio_addon_discovery_confirm_only( result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "a0d7b954_uptime-kuma" assert result["data"] == { @@ -357,6 +356,7 @@ async def test_hassio_addon_discovery_confirm_only( CONF_VERIFY_SSL: True, CONF_API_KEY: None, } + assert result["result"].unique_id == "1234" assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/v2c/test_config_flow.py b/tests/components/v2c/test_config_flow.py index a6e3529e24b6..8c2c740078eb 100644 --- a/tests/components/v2c/test_config_flow.py +++ b/tests/components/v2c/test_config_flow.py @@ -28,10 +28,10 @@ async def test_full_flow( ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "EVSE 1.1.1.1" assert result["data"] == {CONF_HOST: "1.1.1.1"} + assert result["result"].unique_id == "ABC123" assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/verisure/test_config_flow.py b/tests/components/verisure/test_config_flow.py index d80b68b4b63b..e1bd8eaa56b5 100644 --- a/tests/components/verisure/test_config_flow.py +++ b/tests/components/verisure/test_config_flow.py @@ -51,7 +51,6 @@ async def test_full_user_flow_single_installation( ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result2.get("type") is FlowResultType.CREATE_ENTRY assert result2.get("title") == "ascending (12345th street)" assert result2.get("data") == { @@ -59,6 +58,7 @@ async def test_full_user_flow_single_installation( CONF_EMAIL: "verisure_my_pages@example.com", CONF_PASSWORD: "SuperS3cr3t!", } + assert result2["result"].unique_id == "12345" assert len(mock_verisure_config_flow.login.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1 @@ -95,7 +95,6 @@ async def test_full_user_flow_multiple_installations( ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result3.get("type") is FlowResultType.CREATE_ENTRY assert result3.get("title") == "descending (54321th street)" assert result3.get("data") == { @@ -103,6 +102,7 @@ async def test_full_user_flow_multiple_installations( CONF_EMAIL: "verisure_my_pages@example.com", CONF_PASSWORD: "SuperS3cr3t!", } + assert result3["result"].unique_id == "54321" assert len(mock_verisure_config_flow.login.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/vicare/test_config_flow.py b/tests/components/vicare/test_config_flow.py index dba1e516ccc1..d0dd37d276ea 100644 --- a/tests/components/vicare/test_config_flow.py +++ b/tests/components/vicare/test_config_flow.py @@ -9,6 +9,7 @@ from homeassistant.config_entries import SOURCE_DHCP, SOURCE_USER from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType from homeassistant.helpers import config_entry_oauth2_flow +from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo from . import MOCK_MAC @@ -147,9 +148,9 @@ async def test_dhcp_flow( result = await _do_oauth_flow(hass, hass_client_no_auth, aioclient_mock, result) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "ViCare" + assert result["result"].unique_id == format_mac(DHCP_INFO.macaddress) async def test_dhcp_single_instance_allowed(hass: HomeAssistant) -> None: diff --git a/tests/components/victron_remote_monitoring/test_config_flow.py b/tests/components/victron_remote_monitoring/test_config_flow.py index 89413a1584b0..bdc79e1c18c0 100644 --- a/tests/components/victron_remote_monitoring/test_config_flow.py +++ b/tests/components/victron_remote_monitoring/test_config_flow.py @@ -57,13 +57,13 @@ async def test_full_flow_success( result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_SITE_ID: str(site1.id)} ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == f"VRM for {site1.name}" assert result["data"] == { CONF_API_TOKEN: "test_token", CONF_SITE_ID: site1.id, } + assert result["result"].unique_id == str(site1.id) assert mock_setup_entry.call_count == 1 @@ -249,12 +249,12 @@ async def test_select_site_duplicate_aborts( result_new2 = await hass.config_entries.flow.async_configure( result_new["flow_id"], {CONF_API_TOKEN: "token3"} ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result_new2["type"] is FlowResultType.CREATE_ENTRY assert result_new2["data"] == { CONF_API_TOKEN: "token3", CONF_SITE_ID: other_site.id, } + assert result_new2["result"].unique_id == str(other_site.id) async def test_reauth_flow_success( diff --git a/tests/components/vistapool/test_config_flow.py b/tests/components/vistapool/test_config_flow.py index a0f0f4e3a176..487e568b6bd4 100644 --- a/tests/components/vistapool/test_config_flow.py +++ b/tests/components/vistapool/test_config_flow.py @@ -20,7 +20,7 @@ from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo -from .conftest import MOCK_PASSWORD, MOCK_POOLS, MOCK_USERNAME +from .conftest import MOCK_PASSWORD, MOCK_POOLS, MOCK_USER_ID, MOCK_USERNAME from tests.common import MockConfigEntry @@ -73,13 +73,13 @@ async def test_user_step( result = await _submit(hass, result["flow_id"]) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == MOCK_USERNAME assert result["data"] == { CONF_USERNAME: MOCK_USERNAME, CONF_PASSWORD: MOCK_PASSWORD, } + assert result["result"].unique_id == MOCK_USER_ID # ── Error Handling (each path also verifies the flow can recover) ─ @@ -262,9 +262,9 @@ async def test_dhcp_discovery_starts_user_flow( result = await _submit(hass, result["flow_id"]) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == MOCK_USERNAME + assert result["result"].unique_id == MOCK_USER_ID async def test_dhcp_discovery_aborts_when_configured( diff --git a/tests/components/vlc_telnet/test_config_flow.py b/tests/components/vlc_telnet/test_config_flow.py index 5362db53f0c9..7d043c02c0ae 100644 --- a/tests/components/vlc_telnet/test_config_flow.py +++ b/tests/components/vlc_telnet/test_config_flow.py @@ -259,10 +259,10 @@ async def test_hassio_flow(hass: HomeAssistant) -> None: result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == test_data.config["name"] assert result2["data"] == test_data.config + assert result2["result"].unique_id == "hassio" assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/volumio/test_config_flow.py b/tests/components/volumio/test_config_flow.py index 09f4e9f89e2f..fa07ae11c84f 100644 --- a/tests/components/volumio/test_config_flow.py +++ b/tests/components/volumio/test_config_flow.py @@ -63,10 +63,10 @@ async def test_form(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "TestVolumio" assert result2["data"] == {**TEST_SYSTEM_INFO, **TEST_CONNECTION} + assert result2["result"].unique_id == TEST_SYSTEM_INFO["id"] assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/volvo/test_config_flow.py b/tests/components/volvo/test_config_flow.py index 943a5af3a818..f3ecda43e10e 100644 --- a/tests/components/volvo/test_config_flow.py +++ b/tests/components/volvo/test_config_flow.py @@ -73,8 +73,8 @@ async def test_single_vin_flow( assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(mock_setup_entry.mock_calls) == 1 - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY + assert result["result"].unique_id == DEFAULT_VIN @pytest.mark.parametrize(("api_key_failure"), [pytest.param(True), pytest.param(False)]) diff --git a/tests/components/watttime/test_config_flow.py b/tests/components/watttime/test_config_flow.py index 2dfb1e601ff7..28d48f56aace 100644 --- a/tests/components/watttime/test_config_flow.py +++ b/tests/components/watttime/test_config_flow.py @@ -247,7 +247,6 @@ async def test_step_user_coordinates( result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=config_coordinates ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "32.87336, -117.22743" assert result["data"] == { @@ -258,6 +257,7 @@ async def test_step_user_coordinates( CONF_BALANCING_AUTHORITY: "PJM New Jersey", CONF_BALANCING_AUTHORITY_ABBREV: "PJM_NJ", } + assert result["result"].unique_id == "32.87336, -117.22743" @pytest.mark.parametrize( @@ -287,7 +287,6 @@ async def test_step_user_home( result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=config_location_type ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "32.87336, -117.22743" assert result["data"] == { @@ -298,3 +297,4 @@ async def test_step_user_home( CONF_BALANCING_AUTHORITY: "PJM New Jersey", CONF_BALANCING_AUTHORITY_ABBREV: "PJM_NJ", } + assert result["result"].unique_id == "32.87336, -117.22743" diff --git a/tests/components/webmin/test_config_flow.py b/tests/components/webmin/test_config_flow.py index 1572cad40e63..dc1d856963fd 100644 --- a/tests/components/webmin/test_config_flow.py +++ b/tests/components/webmin/test_config_flow.py @@ -32,10 +32,18 @@ async def user_flow(hass: HomeAssistant) -> str: @pytest.mark.parametrize( - "fixture", ["webmin_update_without_mac.json", "webmin_update.json"] + ("fixture", "expected_unique_id"), + [ + ("webmin_update_without_mac.json", None), + ("webmin_update.json", "12:34:56:78:9a:bc"), + ], ) async def test_form_user( - hass: HomeAssistant, user_flow: str, mock_setup_entry: AsyncMock, fixture: str + hass: HomeAssistant, + user_flow: str, + mock_setup_entry: AsyncMock, + fixture: str, + expected_unique_id: str | None, ) -> None: """Test a successful user initiated flow.""" with patch( @@ -46,10 +54,10 @@ async def test_form_user( user_flow, TEST_USER_INPUT ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_USER_INPUT[CONF_HOST] assert result["options"] == TEST_USER_INPUT + assert result["result"].unique_id == expected_unique_id assert len(mock_setup_entry.mock_calls) == 1 @@ -121,10 +129,10 @@ async def test_duplicate_entry(hass: HomeAssistant, user_flow: str) -> None: ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_USER_INPUT[CONF_HOST] assert result["options"] == TEST_USER_INPUT + assert result["result"].unique_id == "12:34:56:78:9a:bc" with patch( "homeassistant.components.webmin.helpers.WebminInstance.update", diff --git a/tests/components/wilight/test_config_flow.py b/tests/components/wilight/test_config_flow.py index 2aa3ba792a19..57ca8ea84f5d 100644 --- a/tests/components/wilight/test_config_flow.py +++ b/tests/components/wilight/test_config_flow.py @@ -164,9 +164,9 @@ async def test_full_ssdp_flow_implementation(hass: HomeAssistant) -> None: result["flow_id"], user_input={} ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == f"WL{WILIGHT_ID}" + assert result["result"].unique_id == UPNP_SERIAL assert result["data"] assert result["data"][CONF_HOST] == HOST diff --git a/tests/components/withings/test_config_flow.py b/tests/components/withings/test_config_flow.py index bcbfd4ebe44b..0c2694ee79a0 100644 --- a/tests/components/withings/test_config_flow.py +++ b/tests/components/withings/test_config_flow.py @@ -364,5 +364,5 @@ async def test_dhcp( assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(mock_setup.mock_calls) == 1 - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY + assert result["result"].unique_id == "600" diff --git a/tests/components/wmspro/test_config_flow.py b/tests/components/wmspro/test_config_flow.py index 8ce5560b446b..99d2ecc4c4ec 100644 --- a/tests/components/wmspro/test_config_flow.py +++ b/tests/components/wmspro/test_config_flow.py @@ -71,12 +71,12 @@ async def test_config_flow_from_dhcp( }, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result.get("type") is FlowResultType.CREATE_ENTRY assert result.get("title") == "1.2.3.4" assert result.get("data") == { CONF_HOST: "1.2.3.4", } + assert result["result"].unique_id == "00:11:22:33:44:55" assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/xiaomi_aqara/test_config_flow.py b/tests/components/xiaomi_aqara/test_config_flow.py index be99a0b51b1a..328df6f4a61c 100644 --- a/tests/components/xiaomi_aqara/test_config_flow.py +++ b/tests/components/xiaomi_aqara/test_config_flow.py @@ -108,7 +108,6 @@ async def test_config_flow_user_success(hass: HomeAssistant) -> None: {const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME assert result["data"] == { @@ -120,6 +119,7 @@ async def test_config_flow_user_success(hass: HomeAssistant) -> None: const.CONF_KEY: TEST_KEY, const.CONF_SID: TEST_SID, } + assert result["result"].unique_id == TEST_MAC async def test_config_flow_user_multiple_success(hass: HomeAssistant) -> None: @@ -161,7 +161,6 @@ async def test_config_flow_user_multiple_success(hass: HomeAssistant) -> None: {const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME assert result["data"] == { @@ -173,6 +172,7 @@ async def test_config_flow_user_multiple_success(hass: HomeAssistant) -> None: const.CONF_KEY: TEST_KEY, const.CONF_SID: TEST_SID, } + assert result["result"].unique_id == TEST_MAC async def test_config_flow_user_no_key_success(hass: HomeAssistant) -> None: @@ -199,7 +199,6 @@ async def test_config_flow_user_no_key_success(hass: HomeAssistant) -> None: {CONF_NAME: TEST_NAME}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME assert result["data"] == { @@ -211,6 +210,7 @@ async def test_config_flow_user_no_key_success(hass: HomeAssistant) -> None: const.CONF_KEY: None, const.CONF_SID: TEST_SID, } + assert result["result"].unique_id == TEST_MAC async def test_config_flow_user_host_mac_success(hass: HomeAssistant) -> None: @@ -247,7 +247,6 @@ async def test_config_flow_user_host_mac_success(hass: HomeAssistant) -> None: {CONF_NAME: TEST_NAME}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME assert result["data"] == { @@ -259,6 +258,7 @@ async def test_config_flow_user_host_mac_success(hass: HomeAssistant) -> None: const.CONF_KEY: None, const.CONF_SID: TEST_SID, } + assert result["result"].unique_id == TEST_MAC async def test_config_flow_user_discovery_error(hass: HomeAssistant) -> None: @@ -442,7 +442,6 @@ async def test_zeroconf_success(hass: HomeAssistant) -> None: {const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME assert result["data"] == { @@ -454,6 +453,7 @@ async def test_zeroconf_success(hass: HomeAssistant) -> None: const.CONF_KEY: TEST_KEY, const.CONF_SID: TEST_SID, } + assert result["result"].unique_id == TEST_MAC async def test_zeroconf_missing_data(hass: HomeAssistant) -> None: diff --git a/tests/components/xiaomi_ble/test_config_flow.py b/tests/components/xiaomi_ble/test_config_flow.py index 45b3f4385f1a..c55fea785492 100644 --- a/tests/components/xiaomi_ble/test_config_flow.py +++ b/tests/components/xiaomi_ble/test_config_flow.py @@ -754,10 +754,10 @@ async def test_async_step_user_short_payload_then_full(hass: HomeAssistant) -> N user_input={"bindkey": "a115210eed7a88e50ad52662e732a9fb"}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["title"] == "Temperature/Humidity Sensor 5384 (LYWSD03MMC)" assert result3["data"] == {"bindkey": "a115210eed7a88e50ad52662e732a9fb"} + assert result3["result"].unique_id == "A4:C1:38:56:53:84" async def test_async_step_user_with_found_devices_v4_encryption( diff --git a/tests/components/xiaomi_miio/test_config_flow.py b/tests/components/xiaomi_miio/test_config_flow.py index 1ee83bb998da..d601263a71c4 100644 --- a/tests/components/xiaomi_miio/test_config_flow.py +++ b/tests/components/xiaomi_miio/test_config_flow.py @@ -170,7 +170,6 @@ async def test_config_flow_gateway_success(hass: HomeAssistant) -> None: {CONF_HOST: TEST_HOST, CONF_TOKEN: TEST_TOKEN}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_MODEL assert result["data"] == { @@ -183,6 +182,7 @@ async def test_config_flow_gateway_success(hass: HomeAssistant) -> None: CONF_MODEL: TEST_MODEL, CONF_MAC: TEST_MAC, } + assert result["result"].unique_id == TEST_MAC async def test_config_flow_gateway_cloud_success(hass: HomeAssistant) -> None: @@ -204,7 +204,6 @@ async def test_config_flow_gateway_cloud_success(hass: HomeAssistant) -> None: }, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME assert result["data"] == { @@ -217,6 +216,7 @@ async def test_config_flow_gateway_cloud_success(hass: HomeAssistant) -> None: CONF_MODEL: TEST_MODEL, CONF_MAC: TEST_MAC, } + assert result["result"].unique_id == TEST_MAC async def test_config_flow_gateway_cloud_multiple_success(hass: HomeAssistant) -> None: @@ -251,7 +251,6 @@ async def test_config_flow_gateway_cloud_multiple_success(hass: HomeAssistant) - {"select_device": f"{TEST_NAME2} - {TEST_MODEL}"}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME2 assert result["data"] == { @@ -264,6 +263,7 @@ async def test_config_flow_gateway_cloud_multiple_success(hass: HomeAssistant) - CONF_MODEL: TEST_MODEL, CONF_MAC: TEST_MAC2, } + assert result["result"].unique_id == TEST_MAC2 async def test_config_flow_gateway_cloud_incomplete(hass: HomeAssistant) -> None: @@ -461,7 +461,6 @@ async def test_zeroconf_gateway_success(hass: HomeAssistant) -> None: }, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME assert result["data"] == { @@ -474,6 +473,7 @@ async def test_zeroconf_gateway_success(hass: HomeAssistant) -> None: CONF_MODEL: TEST_MODEL, CONF_MAC: TEST_MAC, } + assert result["result"].unique_id == TEST_MAC async def test_zeroconf_unknown_device(hass: HomeAssistant) -> None: diff --git a/tests/components/yale_smart_alarm/test_config_flow.py b/tests/components/yale_smart_alarm/test_config_flow.py index 9e9d58959078..bbbdc434ed03 100644 --- a/tests/components/yale_smart_alarm/test_config_flow.py +++ b/tests/components/yale_smart_alarm/test_config_flow.py @@ -41,7 +41,6 @@ async def test_form(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "test-username" assert result2["data"] == { @@ -49,6 +48,7 @@ async def test_form(hass: HomeAssistant) -> None: "password": "test-password", "area_id": "1", } + assert result2["result"].unique_id == "test-username" assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/yalexs_ble/test_config_flow.py b/tests/components/yalexs_ble/test_config_flow.py index ac9c5a16c652..248a5dd96b37 100644 --- a/tests/components/yalexs_ble/test_config_flow.py +++ b/tests/components/yalexs_ble/test_config_flow.py @@ -611,9 +611,9 @@ async def test_integration_discovery_prefers_address(hass: HomeAssistant) -> Non result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["data"][CONF_ADDRESS] == YALE_ACCESS_LOCK_DISCOVERY_INFO.address + assert result2["result"].unique_id == YALE_ACCESS_LOCK_DISCOVERY_INFO.address async def test_integration_discovery_device_not_found(hass: HomeAssistant) -> None: @@ -757,7 +757,6 @@ async def test_bluetooth_discovery_with_cached_config( result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={} ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "Front Door" assert result["data"] == { @@ -766,6 +765,7 @@ async def test_bluetooth_discovery_with_cached_config( CONF_KEY: "2fd51b8621c6a139eaffbedcb846b60f", CONF_SLOT: 66, } + assert result["result"].unique_id == YALE_ACCESS_LOCK_DISCOVERY_INFO.address async def test_integration_discovery_updates_key_unique_local_name( diff --git a/tests/components/yamaha_musiccast/test_config_flow.py b/tests/components/yamaha_musiccast/test_config_flow.py index 381cd0a29df1..515dcfe0a831 100644 --- a/tests/components/yamaha_musiccast/test_config_flow.py +++ b/tests/components/yamaha_musiccast/test_config_flow.py @@ -227,7 +227,6 @@ async def test_user_input_device_found( {"host": "127.0.0.1"}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result2["type"] is FlowResultType.CREATE_ENTRY assert isinstance(result2["result"], ConfigEntry) assert result2["data"] == { @@ -235,6 +234,7 @@ async def test_user_input_device_found( "serial": "1234567890", "upnp_description": "http://127.0.0.1:9000/MediaRenderer/desc.xml", } + assert result2["result"].unique_id == "1234567890" async def test_user_input_device_found_no_ssdp( @@ -253,7 +253,6 @@ async def test_user_input_device_found_no_ssdp( {"host": "127.0.0.1"}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result2["type"] is FlowResultType.CREATE_ENTRY assert isinstance(result2["result"], ConfigEntry) assert result2["data"] == { @@ -261,6 +260,7 @@ async def test_user_input_device_found_no_ssdp( "serial": "1234567890", "upnp_description": "http://127.0.0.1:49154/MediaRenderer/desc.xml", } + assert result2["result"].unique_id == "1234567890" # SSDP Flows @@ -313,7 +313,6 @@ async def test_ssdp_discovery_successful_add_device( {}, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result2["type"] is FlowResultType.CREATE_ENTRY assert isinstance(result2["result"], ConfigEntry) assert result2["data"] == { @@ -321,6 +320,7 @@ async def test_ssdp_discovery_successful_add_device( "serial": "1234567890", "upnp_description": "http://127.0.0.1/desc.xml", } + assert result2["result"].unique_id == "1234567890" async def test_ssdp_discovery_existing_device_update( diff --git a/tests/components/yardian/test_config_flow.py b/tests/components/yardian/test_config_flow.py index 5f58bbb03348..f16e22eb39b2 100644 --- a/tests/components/yardian/test_config_flow.py +++ b/tests/components/yardian/test_config_flow.py @@ -26,7 +26,6 @@ async def test_form(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == PRODUCT_NAME assert result["data"] == { @@ -35,6 +34,7 @@ async def test_form(hass: HomeAssistant) -> None: "name": "fake_name", "yid": "fake_yid", } + assert result["result"].unique_id == "fake_yid" @pytest.mark.parametrize( diff --git a/tests/components/zimi/test_config_flow.py b/tests/components/zimi/test_config_flow.py index 25978ef4d2b6..c0651b3c8291 100644 --- a/tests/components/zimi/test_config_flow.py +++ b/tests/components/zimi/test_config_flow.py @@ -116,13 +116,13 @@ async def test_user_discovery_success_selection( }, ) - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"] == { "host": INPUT_HOST_EXTRA, "port": INPUT_PORT_EXTRA, "mac": format_mac(INPUT_MAC_EXTRA), } + assert result["result"].unique_id == format_mac(INPUT_MAC_EXTRA) async def test_user_discovery_duplicates( diff --git a/tests/components/zwave_me/test_config_flow.py b/tests/components/zwave_me/test_config_flow.py index 794534a46174..d0d101f02895 100644 --- a/tests/components/zwave_me/test_config_flow.py +++ b/tests/components/zwave_me/test_config_flow.py @@ -53,13 +53,13 @@ async def test_form(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "ws://192.168.1.14" assert result2["data"] == { "url": "ws://192.168.1.14", "token": "test-token", } + assert result2["result"].unique_id == "test_uuid" assert len(mock_setup_entry.mock_calls) == 1 @@ -91,13 +91,13 @@ async def test_zeroconf(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - # pylint: disable-next=home-assistant-tests-config-flow-unique-id assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "ws://192.168.1.14" assert result2["data"] == { "url": "ws://192.168.1.14", "token": "test-token", } + assert result2["result"].unique_id == "test_uuid" assert len(mock_setup_entry.mock_calls) == 1