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:
epenet 2023-05-24 09:38:29 +02:00 committed by GitHub
parent 326d80f4f7
commit dc14b83249
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View file

@ -188,6 +188,14 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
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:
"""Finish set up once demo platforms are set up."""
switches: list[str] | None = None

View file

@ -216,7 +216,9 @@ async def test_get_entries(hass: HomeAssistant, client, clear_handlers) -> None:
async def test_remove_entry(hass: HomeAssistant, client) -> None:
"""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)
resp = await client.delete(f"/api/config/config_entries/entry/{entry.entry_id}")
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:
"""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)
resp = await client.post(
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", {})
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)
assert entry.pref_disable_new_entities is False
@ -1118,7 +1124,9 @@ async def test_disable_entry(
assert await async_setup_component(hass, "config", {})
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)
assert entry.disabled_by is None