From 704ad679173c077b30280b1545a0d7dc0f2fc96e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 12 Feb 2024 21:59:26 -0600 Subject: [PATCH] Ensure hue tests add config entry before updating it (#110428) --- tests/components/hue/test_light_v1.py | 2 +- tests/components/hue/test_migration.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/components/hue/test_light_v1.py b/tests/components/hue/test_light_v1.py index da11068a34f..2e67eb6d0e1 100644 --- a/tests/components/hue/test_light_v1.py +++ b/tests/components/hue/test_light_v1.py @@ -178,10 +178,10 @@ async def setup_bridge(hass: HomeAssistant, mock_bridge_v1): """Load the Hue light platform with the provided bridge.""" hass.config.components.add(hue.DOMAIN) config_entry = create_config_entry() + config_entry.add_to_hass(hass) hass.config_entries.async_update_entry( config_entry, options={CONF_ALLOW_HUE_GROUPS: True} ) - config_entry.add_to_hass(hass) config_entry.mock_state(hass, ConfigEntryState.LOADED) mock_bridge_v1.config_entry = config_entry hass.data[hue.DOMAIN] = {config_entry.entry_id: mock_bridge_v1} diff --git a/tests/components/hue/test_migration.py b/tests/components/hue/test_migration.py index 5ca182d1761..0a6c24a5756 100644 --- a/tests/components/hue/test_migration.py +++ b/tests/components/hue/test_migration.py @@ -14,6 +14,7 @@ async def test_migrate_api_key(hass: HomeAssistant) -> None: domain=hue.DOMAIN, data={"host": "0.0.0.0", "api_version": 2, "username": "abcdefgh"}, ) + config_entry.add_to_hass(hass) await hue.migration.check_migration(hass, config_entry) # the username property should have been migrated to api_key assert config_entry.data == { @@ -29,6 +30,7 @@ async def test_auto_switchover(hass: HomeAssistant) -> None: domain=hue.DOMAIN, data={"host": "0.0.0.0", "api_version": 1, "username": "abcdefgh"}, ) + config_entry.add_to_hass(hass) with patch.object(hue.migration, "is_v2_bridge", retun_value=True), patch.object( hue.migration, "handle_v2_migration"