hass-core/tests/components/simplisafe/test_init.py
Joost Lekkerkerker 6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00

51 lines
1.6 KiB
Python

"""Define tests for SimpliSafe setup."""
from unittest.mock import patch
from homeassistant.components.simplisafe import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.setup import async_setup_component
async def test_base_station_migration(
hass: HomeAssistant, api, config, config_entry
) -> None:
"""Test that errors are shown when duplicates are added."""
old_identifers = (DOMAIN, 12345)
new_identifiers = (DOMAIN, "12345")
device_registry = dr.async_get(hass)
device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
identifiers={old_identifers},
manufacturer="SimpliSafe",
name="old",
)
with (
patch(
"homeassistant.components.simplisafe.config_flow.API.async_from_auth",
return_value=api,
),
patch(
"homeassistant.components.simplisafe.API.async_from_auth",
return_value=api,
),
patch(
"homeassistant.components.simplisafe.API.async_from_refresh_token",
return_value=api,
),
patch(
"homeassistant.components.simplisafe.SimpliSafe._async_start_websocket_loop"
),
patch(
"homeassistant.components.simplisafe.PLATFORMS",
[],
),
):
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()
assert device_registry.async_get_device(identifiers={old_identifers}) is None
assert device_registry.async_get_device(identifiers={new_identifiers}) is not None