Vizio: when checking new host against existing config entry hosts, make check hostname aware (#37397)
* make ip check hostname aware * add executor job for sync function doing IO and remove errant comma * revert change to update new_data explicitly for options keys since it is already done later * empty commit to retrigger CI
This commit is contained in:
1 parent
368116d242
commit
572d5a09cd
4 files changed
+84
-6
No files matched your search
@@ -853,3 +853,55 @@ async def test_zeroconf_abort_when_ignored(
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_zeroconf_flow_already_configured_hostname(
|
||||
hass: HomeAssistantType,
|
||||
vizio_connect: pytest.fixture,
|
||||
vizio_bypass_setup: pytest.fixture,
|
||||
vizio_hostname_check: pytest.fixture,
|
||||
) -> None:
|
||||
"""Test entity is already configured during zeroconf setup when existing entry uses hostname."""
|
||||
config = MOCK_SPEAKER_CONFIG.copy()
|
||||
config[CONF_HOST] = "hostname"
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN, data=config, options={CONF_VOLUME_STEP: VOLUME_STEP}
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
# Try rediscovering same device
|
||||
discovery_info = MOCK_ZEROCONF_SERVICE_INFO.copy()
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||
)
|
||||
|
||||
# Flow should abort because device is already setup
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured_device"
|
||||
|
||||
|
||||
async def test_import_flow_already_configured_hostname(
|
||||
hass: HomeAssistantType,
|
||||
vizio_connect: pytest.fixture,
|
||||
vizio_bypass_setup: pytest.fixture,
|
||||
vizio_hostname_check: pytest.fixture,
|
||||
) -> None:
|
||||
"""Test entity is already configured during import setup when existing entry uses hostname."""
|
||||
config = MOCK_SPEAKER_CONFIG.copy()
|
||||
config[CONF_HOST] = "hostname"
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN, data=config, options={CONF_VOLUME_STEP: VOLUME_STEP}
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=vol.Schema(VIZIO_SCHEMA)(MOCK_SPEAKER_CONFIG),
|
||||
)
|
||||
|
||||
# Flow should abort because device was updated
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "updated_entry"
|
||||
|
||||
assert entry.data[CONF_HOST] == HOST
|
||||
Reference in new issue
Block a user