mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Add ability to unload demo integration (#92515)
* Add unload to demo integration * Adjust config tests to use kitchen_sink * Use async_unload_platforms
This commit is contained in:
parent
326d80f4f7
commit
dc14b83249
@ -188,6 +188,14 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
||||||
|
"""Unload a config entry."""
|
||||||
|
await hass.config_entries.async_unload_platforms(
|
||||||
|
config_entry, COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def finish_setup(hass: HomeAssistant, config: ConfigType) -> None:
|
async def finish_setup(hass: HomeAssistant, config: ConfigType) -> None:
|
||||||
"""Finish set up once demo platforms are set up."""
|
"""Finish set up once demo platforms are set up."""
|
||||||
switches: list[str] | None = None
|
switches: list[str] | None = None
|
||||||
|
@ -216,7 +216,9 @@ async def test_get_entries(hass: HomeAssistant, client, clear_handlers) -> None:
|
|||||||
|
|
||||||
async def test_remove_entry(hass: HomeAssistant, client) -> None:
|
async def test_remove_entry(hass: HomeAssistant, client) -> None:
|
||||||
"""Test removing an entry via the API."""
|
"""Test removing an entry via the API."""
|
||||||
entry = MockConfigEntry(domain="demo", state=core_ce.ConfigEntryState.LOADED)
|
entry = MockConfigEntry(
|
||||||
|
domain="kitchen_sink", state=core_ce.ConfigEntryState.LOADED
|
||||||
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
resp = await client.delete(f"/api/config/config_entries/entry/{entry.entry_id}")
|
resp = await client.delete(f"/api/config/config_entries/entry/{entry.entry_id}")
|
||||||
assert resp.status == HTTPStatus.OK
|
assert resp.status == HTTPStatus.OK
|
||||||
@ -227,7 +229,9 @@ async def test_remove_entry(hass: HomeAssistant, client) -> None:
|
|||||||
|
|
||||||
async def test_reload_entry(hass: HomeAssistant, client) -> None:
|
async def test_reload_entry(hass: HomeAssistant, client) -> None:
|
||||||
"""Test reloading an entry via the API."""
|
"""Test reloading an entry via the API."""
|
||||||
entry = MockConfigEntry(domain="demo", state=core_ce.ConfigEntryState.LOADED)
|
entry = MockConfigEntry(
|
||||||
|
domain="kitchen_sink", state=core_ce.ConfigEntryState.LOADED
|
||||||
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
resp = await client.post(
|
resp = await client.post(
|
||||||
f"/api/config/config_entries/entry/{entry.entry_id}/reload"
|
f"/api/config/config_entries/entry/{entry.entry_id}/reload"
|
||||||
@ -1021,7 +1025,9 @@ async def test_update_prefrences(
|
|||||||
assert await async_setup_component(hass, "config", {})
|
assert await async_setup_component(hass, "config", {})
|
||||||
ws_client = await hass_ws_client(hass)
|
ws_client = await hass_ws_client(hass)
|
||||||
|
|
||||||
entry = MockConfigEntry(domain="demo", state=core_ce.ConfigEntryState.LOADED)
|
entry = MockConfigEntry(
|
||||||
|
domain="kitchen_sink", state=core_ce.ConfigEntryState.LOADED
|
||||||
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
assert entry.pref_disable_new_entities is False
|
assert entry.pref_disable_new_entities is False
|
||||||
@ -1118,7 +1124,9 @@ async def test_disable_entry(
|
|||||||
assert await async_setup_component(hass, "config", {})
|
assert await async_setup_component(hass, "config", {})
|
||||||
ws_client = await hass_ws_client(hass)
|
ws_client = await hass_ws_client(hass)
|
||||||
|
|
||||||
entry = MockConfigEntry(domain="demo", state=core_ce.ConfigEntryState.LOADED)
|
entry = MockConfigEntry(
|
||||||
|
domain="kitchen_sink", state=core_ce.ConfigEntryState.LOADED
|
||||||
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
assert entry.disabled_by is None
|
assert entry.disabled_by is None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user