mirror of
https://github.com/home-assistant/core.git
synced 2026-02-15 07:36:16 +00:00
Add coverage for Shelly init (#162497)
This commit is contained in:
@@ -175,6 +175,7 @@ async def _async_setup_block_entry(
|
||||
)
|
||||
# https://github.com/home-assistant/core/pull/48076
|
||||
if device_entry and entry.entry_id not in device_entry.config_entries:
|
||||
LOGGER.debug("Detected first time setup for device %s", entry.title)
|
||||
device_entry = None
|
||||
|
||||
sleep_period = entry.data.get(CONF_SLEEP_PERIOD)
|
||||
@@ -288,6 +289,7 @@ async def _async_setup_rpc_entry(hass: HomeAssistant, entry: ShellyConfigEntry)
|
||||
)
|
||||
# https://github.com/home-assistant/core/pull/48076
|
||||
if device_entry and entry.entry_id not in device_entry.config_entries:
|
||||
LOGGER.debug("Detected first time setup for device %s", entry.title)
|
||||
device_entry = None
|
||||
|
||||
sleep_period = entry.data.get(CONF_SLEEP_PERIOD)
|
||||
|
||||
@@ -37,12 +37,18 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.helpers.device_registry import DeviceRegistry, format_mac
|
||||
from homeassistant.helpers.device_registry import (
|
||||
CONNECTION_NETWORK_MAC,
|
||||
DeviceRegistry,
|
||||
format_mac,
|
||||
)
|
||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from . import MOCK_MAC, init_integration, mutate_rpc_device_status, register_sub_device
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_custom_coap_port(
|
||||
hass: HomeAssistant, mock_block_device: Mock, caplog: pytest.LogCaptureFixture
|
||||
@@ -126,7 +132,15 @@ async def test_shared_device_mac(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test first time shared device with another domain."""
|
||||
other_entry = MockConfigEntry(domain="other_domain", unique_id=MOCK_MAC)
|
||||
other_entry.add_to_hass(hass)
|
||||
device_registry.async_get_or_create(
|
||||
config_entry_id=other_entry.entry_id,
|
||||
connections={(CONNECTION_NETWORK_MAC, MOCK_MAC)},
|
||||
)
|
||||
|
||||
await init_integration(hass, gen, sleep_period=1000)
|
||||
assert "Detected first time setup for device" in caplog.text
|
||||
assert "will resume when device is online" in caplog.text
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user