Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions homeassistant/components/local_calendar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.data[DOMAIN].pop(entry.entry_id)

return unload_ok


async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Handle removal of an entry."""
key = slugify(entry.data[CONF_CALENDAR_NAME])
path = Path(hass.config.path(STORAGE_PATH.format(key=key)))

def unlink(path: Path) -> None:
path.unlink(missing_ok=True)

await hass.async_add_executor_job(unlink, path)
18 changes: 18 additions & 0 deletions tests/components/local_calendar/test_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Tests for init platform of local calendar."""

from unittest.mock import patch

from homeassistant.core import HomeAssistant

from tests.common import MockConfigEntry


async def test_remove_config_entry(
hass: HomeAssistant, setup_integration: None, config_entry: MockConfigEntry
) -> None:
"""Test removing a config entry."""

with patch("homeassistant.components.local_calendar.Path.unlink") as unlink_mock:
assert await hass.config_entries.async_remove(config_entry.entry_id)
await hass.async_block_till_done()
unlink_mock.assert_called_once()