From de4393926750cde09efcd6e6aac1024c20d4f3d8 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 6 Feb 2024 15:29:14 -0600 Subject: [PATCH] update tests --- homeassistant/components/dlna_dmr/media_player.py | 5 +++-- tests/components/dlna_dmr/test_media_player.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/dlna_dmr/media_player.py b/homeassistant/components/dlna_dmr/media_player.py index bbe8f1c442b..ac63deddd45 100644 --- a/homeassistant/components/dlna_dmr/media_player.py +++ b/homeassistant/components/dlna_dmr/media_player.py @@ -155,10 +155,10 @@ class DlnaDmrEntity(MediaPlayerEntity): self.browse_unfiltered = browse_unfiltered self._device_lock = asyncio.Lock() self._background_setup_task: asyncio.Task[None] | None = None + self._updated_registry: bool = False # Device info will be updated when the device is connected self._attr_device_info = dr.DeviceInfo( connections={(dr.CONNECTION_UPNP, self.udn)}, - default_name=name, ) async def async_added_to_hass(self) -> None: @@ -374,9 +374,10 @@ class DlnaDmrEntity(MediaPlayerEntity): if not self.registry_entry or not self.registry_entry.config_entry_id: return # No config registry entry to link to - if self.registry_entry.device_id and not set_mac: + if self.registry_entry.device_id and not set_mac and self._updated_registry: return # No new information + self._updated_registry = True connections = set() # Connections based on the root device's UDN, and the DMR embedded # device's UDN. They may be the same, if the DMR is the root device. diff --git a/tests/components/dlna_dmr/test_media_player.py b/tests/components/dlna_dmr/test_media_player.py index e19d9170122..dfce8f42fd0 100644 --- a/tests/components/dlna_dmr/test_media_player.py +++ b/tests/components/dlna_dmr/test_media_player.py @@ -1349,7 +1349,9 @@ async def test_unavailable_device( connections={(CONNECTION_UPNP, MOCK_DEVICE_UDN)}, identifiers=set(), ) - assert device is None + assert device is not None + assert device.name is None + assert device.manufacturer is None # Unload config entry to clean up assert await hass.config_entries.async_remove(config_entry_mock.entry_id) == { @@ -1379,7 +1381,6 @@ async def test_become_available( # Cause connection attempts to fail before adding entity domain_data_mock.upnp_factory.async_create_device.side_effect = UpnpConnectionError mock_entity_id = await setup_mock_component(hass, config_entry_mock) - await async_update_entity(hass, mock_entity_id) mock_state = hass.states.get(mock_entity_id) assert mock_state is not None assert mock_state.state == ha_const.STATE_UNAVAILABLE @@ -1390,7 +1391,7 @@ async def test_become_available( connections={(CONNECTION_UPNP, MOCK_DEVICE_UDN)}, identifiers=set(), ) - assert device is None + assert device is not None # Mock device is now available. domain_data_mock.upnp_factory.async_create_device.side_effect = None