mirror of
https://github.com/home-assistant/core.git
synced 2026-08-07 13:55:32 +01:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
"""Tests for the Dyson Infrared config entry setup/unload."""
|
|
|
|
from unittest.mock import patch
|
|
|
|
from homeassistant.components.dyson_infrared import PLATFORMS
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
async def test_async_setup_entry(hass: HomeAssistant) -> None:
|
|
"""Test setting up the Dyson Infrared config entry."""
|
|
entry = MockConfigEntry(domain="dyson_infrared")
|
|
entry.add_to_hass(hass)
|
|
|
|
with patch.object(
|
|
hass.config_entries, "async_forward_entry_setups"
|
|
) as mock_forward:
|
|
result = await hass.config_entries.async_setup(entry.entry_id)
|
|
|
|
assert result is True
|
|
mock_forward.assert_called_once_with(entry, PLATFORMS)
|
|
|
|
|
|
async def test_async_unload_entry(hass: HomeAssistant) -> None:
|
|
"""Test unloading a config entry forwards unload to platforms."""
|
|
entry = MockConfigEntry(domain="dyson_infrared")
|
|
entry.add_to_hass(hass)
|
|
|
|
with patch.object(hass.config_entries, "async_forward_entry_setups"):
|
|
await hass.config_entries.async_setup(entry.entry_id)
|
|
|
|
with patch.object(
|
|
hass.config_entries, "async_unload_platforms", return_value=True
|
|
) as mock_unload:
|
|
result = await hass.config_entries.async_unload(entry.entry_id)
|
|
|
|
assert result is True
|
|
mock_unload.assert_called_once_with(entry, PLATFORMS)
|