Fix Vodafone Station config entry unload (#143371)

pull/135151/head
Simone Chemelli 2025-04-20 23:56:09 +02:00 committed by GitHub
parent e86bffdf89
commit ee3ee5b165
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 3 deletions

View File

@ -3,7 +3,6 @@
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform
from homeassistant.core import HomeAssistant
from .const import DOMAIN
from .coordinator import VodafoneConfigEntry, VodafoneStationRouter
PLATFORMS = [Platform.BUTTON, Platform.DEVICE_TRACKER, Platform.SENSOR]
@ -36,7 +35,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) ->
coordinator = entry.runtime_data
await coordinator.api.logout()
await coordinator.api.close()
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok

View File

@ -5,7 +5,7 @@ from datetime import UTC, datetime
from aiovodafone import VodafoneStationDevice
import pytest
from homeassistant.components.vodafone_station import DOMAIN
from homeassistant.components.vodafone_station.const import DOMAIN
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from .const import DEVICE_1_HOST, DEVICE_1_MAC, DEVICE_2_MAC

View File

@ -3,6 +3,8 @@
from unittest.mock import AsyncMock
from homeassistant.components.device_tracker import CONF_CONSIDER_HOME
from homeassistant.components.vodafone_station.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
@ -31,3 +33,21 @@ async def test_reload_config_entry_with_options(
assert result["data"] == {
CONF_CONSIDER_HOME: 37,
}
async def test_unload_entry(
hass: HomeAssistant,
mock_vodafone_station_router: AsyncMock,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test unloading the config entry."""
await setup_integration(hass, mock_config_entry)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert mock_config_entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN)