mirror of
https://github.com/home-assistant/core.git
synced 2026-09-28 02:18:10 -04:00
Handle WLED devices with CCT channels (#64581)
This commit is contained in:
@@ -139,6 +139,23 @@ async def test_user_device_exists_abort(
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
||||
|
||||
async def test_user_with_cct_channel_abort(
|
||||
hass: HomeAssistant,
|
||||
mock_wled_config_flow: MagicMock,
|
||||
) -> None:
|
||||
"""Test we abort user flow if WLED device uses a CCT channel."""
|
||||
mock_wled_config_flow.update.return_value.info.leds.cct = True
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data={CONF_HOST: "192.168.1.123"},
|
||||
)
|
||||
|
||||
assert result.get("type") == RESULT_TYPE_ABORT
|
||||
assert result.get("reason") == "cct_unsupported"
|
||||
|
||||
|
||||
async def test_zeroconf_without_mac_device_exists_abort(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
@@ -187,6 +204,30 @@ async def test_zeroconf_with_mac_device_exists_abort(
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
||||
|
||||
async def test_zeroconf_with_cct_channel_abort(
|
||||
hass: HomeAssistant,
|
||||
mock_wled_config_flow: MagicMock,
|
||||
) -> None:
|
||||
"""Test we abort zeroconf flow if WLED device uses a CCT channel."""
|
||||
mock_wled_config_flow.update.return_value.info.leds.cct = True
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.1.123",
|
||||
hostname="example.local.",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={CONF_MAC: "aabbccddeeff"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
assert result.get("type") == RESULT_TYPE_ABORT
|
||||
assert result.get("reason") == "cct_unsupported"
|
||||
|
||||
|
||||
async def test_options_flow(
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
|
||||
@@ -68,3 +68,21 @@ async def test_setting_unique_id(
|
||||
"""Test we set unique ID if not set yet."""
|
||||
assert hass.data[DOMAIN]
|
||||
assert init_integration.unique_id == "aabbccddeeff"
|
||||
|
||||
|
||||
async def test_error_config_entry_with_cct_channel(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_wled: AsyncMock,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test the WLED fails entry setup with a CCT channel."""
|
||||
mock_wled.update.return_value.info.leds.cct = True
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Ensure config entry is errored and are connected and disconnected
|
||||
assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR
|
||||
assert "has a CCT channel, which is not supported" in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user