mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix Vizio async_unload_entry bug (#40210)
This commit is contained in:
parent
ed4ab403de
commit
d0a5feda44
@ -94,7 +94,7 @@ async def async_unload_entry(
|
||||
and entry.data[CONF_DEVICE_CLASS] == DEVICE_CLASS_TV
|
||||
for entry in hass.config_entries.async_entries(DOMAIN)
|
||||
):
|
||||
hass.data[DOMAIN].pop(CONF_APPS)
|
||||
hass.data[DOMAIN].pop(CONF_APPS, None)
|
||||
|
||||
if not hass.data[DOMAIN]:
|
||||
hass.data.pop(DOMAIN)
|
||||
|
@ -6,7 +6,7 @@ from homeassistant.components.vizio.const import DOMAIN
|
||||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .const import MOCK_USER_VALID_TV_CONFIG, UNIQUE_ID
|
||||
from .const import MOCK_SPEAKER_CONFIG, MOCK_USER_VALID_TV_CONFIG, UNIQUE_ID
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@ -24,12 +24,12 @@ async def test_setup_component(
|
||||
assert len(hass.states.async_entity_ids(MP_DOMAIN)) == 1
|
||||
|
||||
|
||||
async def test_load_and_unload(
|
||||
async def test_tv_load_and_unload(
|
||||
hass: HomeAssistantType,
|
||||
vizio_connect: pytest.fixture,
|
||||
vizio_update: pytest.fixture,
|
||||
) -> None:
|
||||
"""Test loading and unloading entry."""
|
||||
"""Test loading and unloading TV entry."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN, data=MOCK_USER_VALID_TV_CONFIG, unique_id=UNIQUE_ID
|
||||
)
|
||||
@ -43,3 +43,24 @@ async def test_load_and_unload(
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_entity_ids(MP_DOMAIN)) == 0
|
||||
assert DOMAIN not in hass.data
|
||||
|
||||
|
||||
async def test_speaker_load_and_unload(
|
||||
hass: HomeAssistantType,
|
||||
vizio_connect: pytest.fixture,
|
||||
vizio_update: pytest.fixture,
|
||||
) -> None:
|
||||
"""Test loading and unloading speaker entry."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN, data=MOCK_SPEAKER_CONFIG, unique_id=UNIQUE_ID
|
||||
)
|
||||
config_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_entity_ids(MP_DOMAIN)) == 1
|
||||
assert DOMAIN in hass.data
|
||||
|
||||
assert await config_entry.async_unload(hass)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_entity_ids(MP_DOMAIN)) == 0
|
||||
assert DOMAIN not in hass.data
|
||||
|
Loading…
x
Reference in New Issue
Block a user