Ensure hue tests add config entry before updating it (#110428)

This commit is contained in:
J. Nick Koston 2024-02-12 21:59:26 -06:00 committed by GitHub
parent a51ecd0614
commit 704ad67917
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -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}

View file

@ -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"