Improve SamsungTV test coverage (#144717)

This commit is contained in:
epenet 2025-05-12 09:23:55 +02:00 committed by GitHub
parent 2333c10915
commit fbe1811e2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
"""Tests for the Samsung TV Integration.""" """Tests for the Samsung TV Integration."""
from typing import Any
from unittest.mock import AsyncMock, Mock, patch from unittest.mock import AsyncMock, Mock, patch
import pytest import pytest
@ -11,7 +12,6 @@ from homeassistant.components.media_player import (
MediaPlayerEntityFeature, MediaPlayerEntityFeature,
) )
from homeassistant.components.samsungtv.const import ( from homeassistant.components.samsungtv.const import (
CONF_MANUFACTURER,
CONF_SESSION_ID, CONF_SESSION_ID,
CONF_SSDP_MAIN_TV_AGENT_LOCATION, CONF_SSDP_MAIN_TV_AGENT_LOCATION,
CONF_SSDP_RENDERING_CONTROL_LOCATION, CONF_SSDP_RENDERING_CONTROL_LOCATION,
@ -179,12 +179,20 @@ async def test_reauth_triggered_encrypted(hass: HomeAssistant) -> None:
assert len(flows_in_progress) == 1 assert len(flows_in_progress) == 1
@pytest.mark.usefixtures("remote_legacy", "remotews", "rest_api_failing") @pytest.mark.usefixtures("remote_legacy", "remoteencws_failing", "rest_api_failing")
async def test_update_imported_legacy_without_method(hass: HomeAssistant) -> None: @pytest.mark.parametrize(
"""Test updating an imported legacy entry without a method.""" "entry_data",
await setup_samsungtv_entry( [
hass, {CONF_HOST: "fake_host", CONF_MANUFACTURER: "Samsung"} {CONF_HOST: "1.2.3.4"}, # Missing port/method
) {CONF_HOST: "1.2.3.4", CONF_PORT: LEGACY_PORT}, # Missing method
{CONF_HOST: "1.2.3.4", CONF_METHOD: METHOD_LEGACY}, # Missing port
],
)
async def test_update_imported_legacy(
hass: HomeAssistant, entry_data: dict[str, Any]
) -> None:
"""Test updating an imported legacy entry."""
await setup_samsungtv_entry(hass, entry_data)
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1 assert len(entries) == 1