mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Assert the unique ID in config flow tests (batch 8) (#185283)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)])
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user