Update vizio host check to handle entries that don't have port (#31463)
* Update vizio host check to handle entries that don't have port * add comment explaining no_port test for future * remove _name_is_same function and support user updating name in config * Update strings.json Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
1 parent
8af9585f12
commit
1efea50654
3 files changed
+78
-12
No files matched your search
@@ -130,6 +130,30 @@ async def test_user_host_already_configured(
|
||||
assert result["errors"] == {CONF_HOST: "host_exists"}
|
||||
|
||||
|
||||
async def test_user_host_already_configured_no_port(
|
||||
hass: HomeAssistantType,
|
||||
vizio_connect: pytest.fixture,
|
||||
vizio_bypass_setup: pytest.fixture,
|
||||
) -> None:
|
||||
"""Test host is already configured during user setup when existing entry has no port."""
|
||||
# Mock entry without port so we can test that the same entry WITH a port will fail
|
||||
no_port_entry = MOCK_SPEAKER_CONFIG.copy()
|
||||
no_port_entry[CONF_HOST] = no_port_entry[CONF_HOST].split(":")[0]
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN, data=no_port_entry, options={CONF_VOLUME_STEP: VOLUME_STEP}
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
fail_entry = MOCK_SPEAKER_CONFIG.copy()
|
||||
fail_entry[CONF_NAME] = "newtestname"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=fail_entry
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["errors"] == {CONF_HOST: "host_exists"}
|
||||
|
||||
|
||||
async def test_user_name_already_configured(
|
||||
hass: HomeAssistantType,
|
||||
vizio_connect: pytest.fixture,
|
||||
@@ -293,13 +317,43 @@ async def test_import_flow_update_options(
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "updated_options"
|
||||
assert result["reason"] == "updated_entry"
|
||||
assert (
|
||||
hass.config_entries.async_get_entry(entry_id).options[CONF_VOLUME_STEP]
|
||||
== VOLUME_STEP + 1
|
||||
)
|
||||
|
||||
|
||||
async def test_import_flow_update_name(
|
||||
hass: HomeAssistantType,
|
||||
vizio_connect: pytest.fixture,
|
||||
vizio_bypass_update: pytest.fixture,
|
||||
) -> None:
|
||||
"""Test import config flow with updated name."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=vol.Schema(VIZIO_SCHEMA)(MOCK_IMPORT_VALID_TV_CONFIG),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["result"].data[CONF_NAME] == NAME
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
entry_id = result["result"].entry_id
|
||||
|
||||
updated_config = MOCK_IMPORT_VALID_TV_CONFIG.copy()
|
||||
updated_config[CONF_NAME] = NAME2
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=vol.Schema(VIZIO_SCHEMA)(updated_config),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "updated_entry"
|
||||
assert hass.config_entries.async_get_entry(entry_id).data[CONF_NAME] == NAME2
|
||||
|
||||
|
||||
async def test_zeroconf_flow(
|
||||
hass: HomeAssistantType,
|
||||
vizio_connect: pytest.fixture,
|
||||
|
||||
Reference in new issue
Block a user