mirror of
https://github.com/home-assistant/core.git
synced 2025-11-15 22:10:09 +00:00
Fix enigma2 integration for devices not reporting MAC address (#133226)
This commit is contained in:
@@ -5,23 +5,37 @@ from unittest.mock import patch
|
||||
from homeassistant.components.enigma2.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from .conftest import TEST_REQUIRED, MockDevice
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_device_without_mac_address(
|
||||
hass: HomeAssistant, device_registry: dr.DeviceRegistry
|
||||
) -> None:
|
||||
"""Test that a device gets successfully registered when the device doesn't report a MAC address."""
|
||||
mock_device = MockDevice()
|
||||
mock_device.mac_address = None
|
||||
with patch(
|
||||
"homeassistant.components.enigma2.coordinator.OpenWebIfDevice.__new__",
|
||||
return_value=mock_device,
|
||||
):
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN, data=TEST_REQUIRED, title="name", unique_id="123456"
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert device_registry.async_get_device({(DOMAIN, entry.unique_id)}) is not None
|
||||
|
||||
|
||||
async def test_unload_entry(hass: HomeAssistant) -> None:
|
||||
"""Test successful unload of entry."""
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.enigma2.coordinator.OpenWebIfDevice.__new__",
|
||||
return_value=MockDevice(),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.enigma2.media_player.async_setup_entry",
|
||||
return_value=True,
|
||||
),
|
||||
with patch(
|
||||
"homeassistant.components.enigma2.coordinator.OpenWebIfDevice.__new__",
|
||||
return_value=MockDevice(),
|
||||
):
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=TEST_REQUIRED, title="name")
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
Reference in New Issue
Block a user