Ensure config_entry is added to hass in tests (#120327)

This commit is contained in:
epenet 2024-06-24 21:00:12 +02:00 committed by GitHub
parent 3b79ab6e18
commit b223cb7bb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -173,14 +173,13 @@ async def test_remove_stale_device(
identifiers={("OtherDomain", 7654321)}, identifiers={("OtherDomain", 7654321)},
) )
config_entry.add_to_hass(hass)
device_registry.async_update_device( device_registry.async_update_device(
device_entry_other.id, device_entry_other.id,
add_config_entry_id=config_entry.entry_id, add_config_entry_id=config_entry.entry_id,
merge_identifiers={(DOMAIN, 7654321)}, merge_identifiers={(DOMAIN, 7654321)},
) )
config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED

View File

@ -171,8 +171,10 @@ async def test_device_registry_config_entry_1(
original_name="ABC", original_name="ABC",
) )
# Add another config entry to the same device # Add another config entry to the same device
other_config_entry = MockConfigEntry()
other_config_entry.add_to_hass(hass)
device_registry.async_update_device( device_registry.async_update_device(
device_entry.id, add_config_entry_id=MockConfigEntry().entry_id device_entry.id, add_config_entry_id=other_config_entry.entry_id
) )
switch_as_x_config_entry = MockConfigEntry( switch_as_x_config_entry = MockConfigEntry(