From c6bdee8dd889c65ff4c18d93e6bd2b0177e4bee6 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 30 Apr 2025 15:26:39 +0200 Subject: [PATCH] Various minor tweaks in samsungtv tests (#143951) --- tests/components/samsungtv/__init__.py | 7 +++++-- tests/components/samsungtv/conftest.py | 6 +++--- tests/components/samsungtv/test_init.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/components/samsungtv/__init__.py b/tests/components/samsungtv/__init__.py index 108a8a3eaa7..06cc2a6848f 100644 --- a/tests/components/samsungtv/__init__.py +++ b/tests/components/samsungtv/__init__.py @@ -2,12 +2,13 @@ from __future__ import annotations +from collections.abc import Mapping from datetime import timedelta +from typing import Any from homeassistant.components.samsungtv.const import DOMAIN, ENTRY_RELOAD_COOLDOWN from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant -from homeassistant.helpers.typing import ConfigType from homeassistant.util import dt as dt_util from tests.common import MockConfigEntry, async_fire_time_changed @@ -22,7 +23,9 @@ async def async_wait_config_entry_reload(hass: HomeAssistant) -> None: await hass.async_block_till_done() -async def setup_samsungtv_entry(hass: HomeAssistant, data: ConfigType) -> ConfigEntry: +async def setup_samsungtv_entry( + hass: HomeAssistant, data: Mapping[str, Any] +) -> ConfigEntry: """Set up mock Samsung TV from config entry data.""" entry = MockConfigEntry( domain=DOMAIN, diff --git a/tests/components/samsungtv/conftest.py b/tests/components/samsungtv/conftest.py index f5ae787ab26..e59c0cc0126 100644 --- a/tests/components/samsungtv/conftest.py +++ b/tests/components/samsungtv/conftest.py @@ -92,13 +92,13 @@ def upnp_factory_fixture() -> Generator[Mock]: @pytest.fixture(name="upnp_device") -def upnp_device_fixture(upnp_factory: Mock) -> Generator[Mock]: +def upnp_device_fixture(upnp_factory: Mock) -> Mock: """Patch async_upnp_client.""" upnp_device = Mock(UpnpDevice) upnp_device.services = {} - with patch.object(upnp_factory, "async_create_device", side_effect=[upnp_device]): - yield upnp_device + upnp_factory.async_create_device.side_effect = [upnp_device] + return upnp_device @pytest.fixture(name="dmr_device") diff --git a/tests/components/samsungtv/test_init.py b/tests/components/samsungtv/test_init.py index f0a5c9284b9..9f1efc0f013 100644 --- a/tests/components/samsungtv/test_init.py +++ b/tests/components/samsungtv/test_init.py @@ -72,7 +72,7 @@ async def test_setup(hass: HomeAssistant) -> None: == SUPPORT_SAMSUNGTV | MediaPlayerEntityFeature.TURN_ON ) - # test host and port + # Ensure service is registered await hass.services.async_call( MP_DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True )