Rename samsung encrypted websocket test fixtures and constants (#144726)

* Rename samsung encrypted websocket test fixtures and constants

* More

* More
This commit is contained in:
epenet 2025-05-12 11:36:22 +02:00 committed by GitHub
parent 7eded95315
commit 63e38b4d8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 215 additions and 143 deletions

View File

@ -209,8 +209,8 @@ def rest_api_failure_fixture() -> Generator[None]:
yield
@pytest.fixture(name="remoteencws_failing")
def remoteencws_failing_fixture() -> Generator[None]:
@pytest.fixture(name="remote_encrypted_websocket_failing")
def remote_encrypted_websocket_failing_fixture() -> Generator[None]:
"""Patch the samsungtvws SamsungTVEncryptedWSAsyncRemote."""
with patch(
"homeassistant.components.samsungtv.bridge.SamsungTVEncryptedWSAsyncRemote.start_listening",
@ -262,30 +262,34 @@ def remote_websocket_fixture() -> Generator[Mock]:
yield remote_websocket
@pytest.fixture(name="remoteencws")
def remoteencws_fixture() -> Generator[Mock]:
@pytest.fixture(name="remote_encrypted_websocket")
def remote_encrypted_websocket_fixture() -> Generator[Mock]:
"""Patch the samsungtvws SamsungTVEncryptedWSAsyncRemote."""
remoteencws = Mock(SamsungTVEncryptedWSAsyncRemote)
remoteencws.__aenter__ = AsyncMock(return_value=remoteencws)
remoteencws.__aexit__ = AsyncMock()
remote_encrypted_websocket = Mock(SamsungTVEncryptedWSAsyncRemote)
remote_encrypted_websocket.__aenter__ = AsyncMock(
return_value=remote_encrypted_websocket
)
remote_encrypted_websocket.__aexit__ = AsyncMock()
def _start_listening(
ws_event_callback: Callable[[str, Any], Awaitable[None] | None] | None = None,
):
remoteencws.ws_event_callback = ws_event_callback
remote_encrypted_websocket.ws_event_callback = ws_event_callback
def _mock_ws_event_callback(event: str, response: Any):
if remoteencws.ws_event_callback:
remoteencws.ws_event_callback(event, response)
if remote_encrypted_websocket.ws_event_callback:
remote_encrypted_websocket.ws_event_callback(event, response)
remoteencws.start_listening.side_effect = _start_listening
remoteencws.raise_mock_ws_event_callback = Mock(side_effect=_mock_ws_event_callback)
remote_encrypted_websocket.start_listening.side_effect = _start_listening
remote_encrypted_websocket.raise_mock_ws_event_callback = Mock(
side_effect=_mock_ws_event_callback
)
with patch(
"homeassistant.components.samsungtv.bridge.SamsungTVEncryptedWSAsyncRemote",
) as remotews_class:
remotews_class.return_value = remoteencws
yield remoteencws
remotews_class.return_value = remote_encrypted_websocket
yield remote_encrypted_websocket
@pytest.fixture(name="mac_address", autouse=True)

View File

@ -3,7 +3,9 @@
from homeassistant.components.samsungtv.const import (
CONF_SESSION_ID,
DOMAIN,
ENCRYPTED_WEBSOCKET_PORT,
LEGACY_PORT,
METHOD_ENCRYPTED_WEBSOCKET,
METHOD_LEGACY,
METHOD_WEBSOCKET,
WEBSOCKET_SSL_PORT,
@ -26,14 +28,10 @@ ENTRYDATA_LEGACY = {
CONF_PORT: LEGACY_PORT,
CONF_METHOD: METHOD_LEGACY,
}
MOCK_CONFIG_ENCRYPTED_WS = {
CONF_HOST: "fake_host",
CONF_NAME: "fake",
CONF_PORT: 8000,
}
MOCK_ENTRYDATA_ENCRYPTED_WS = {
**MOCK_CONFIG_ENCRYPTED_WS,
CONF_METHOD: "encrypted",
ENTRYDATA_ENCRYPTED_WEBSOCKET = {
CONF_HOST: "10.10.12.34",
CONF_PORT: ENCRYPTED_WEBSOCKET_PORT,
CONF_METHOD: METHOD_ENCRYPTED_WEBSOCKET,
CONF_MAC: "aa:bb:cc:dd:ee:ff",
CONF_TOKEN: "037739871315caef138547b03e348b72",
CONF_SESSION_ID: "2",

View File

@ -45,10 +45,9 @@
'device_info': None,
'entry': dict({
'data': dict({
'host': 'fake_host',
'host': '10.10.12.34',
'mac': 'aa:bb:cc:dd:ee:ff',
'method': 'encrypted',
'name': 'fake',
'port': 8000,
'session_id': '**REDACTED**',
'token': '**REDACTED**',
@ -104,11 +103,10 @@
}),
'entry': dict({
'data': dict({
'host': 'fake_host',
'host': '10.10.12.34',
'mac': 'aa:bb:cc:dd:ee:ff',
'method': 'encrypted',
'model': 'UE48JU6400',
'name': 'fake',
'port': 8000,
'session_id': '**REDACTED**',
'token': '**REDACTED**',

View File

@ -55,9 +55,9 @@ from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
from homeassistant.setup import async_setup_component
from .const import (
ENTRYDATA_ENCRYPTED_WEBSOCKET,
ENTRYDATA_LEGACY,
ENTRYDATA_WEBSOCKET,
MOCK_ENTRYDATA_ENCRYPTED_WS,
MOCK_SSDP_DATA,
MOCK_SSDP_DATA_MAIN_TV_AGENT_ST,
MOCK_SSDP_DATA_RENDERING_CONTROL_ST,
@ -193,7 +193,9 @@ async def test_user_legacy_does_not_ok_first_time(hass: HomeAssistant) -> None:
assert result3["result"].unique_id is None
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_user_websocket(hass: HomeAssistant) -> None:
"""Test starting a flow by user."""
with patch(
@ -220,7 +222,7 @@ async def test_user_websocket(hass: HomeAssistant) -> None:
assert result["result"].unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remoteencws", "rest_api_non_ssl_only")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api_non_ssl_only")
async def test_user_encrypted_websocket(
hass: HomeAssistant,
) -> None:
@ -313,7 +315,7 @@ async def test_user_legacy_not_supported(hass: HomeAssistant) -> None:
assert result["reason"] == RESULT_NOT_SUPPORTED
@pytest.mark.usefixtures("rest_api", "remoteencws_failing")
@pytest.mark.usefixtures("rest_api", "remote_encrypted_websocket_failing")
async def test_user_websocket_not_supported(hass: HomeAssistant) -> None:
"""Test starting a flow by user for not supported device."""
with (
@ -334,7 +336,7 @@ async def test_user_websocket_not_supported(hass: HomeAssistant) -> None:
assert result["reason"] == RESULT_NOT_SUPPORTED
@pytest.mark.usefixtures("rest_api", "remoteencws_failing")
@pytest.mark.usefixtures("rest_api", "remote_encrypted_websocket_failing")
async def test_user_websocket_access_denied(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
) -> None:
@ -358,7 +360,7 @@ async def test_user_websocket_access_denied(
assert "Please check the Device Connection Manager on your TV" in caplog.text
@pytest.mark.usefixtures("rest_api", "remoteencws_failing")
@pytest.mark.usefixtures("rest_api", "remote_encrypted_websocket_failing")
async def test_user_websocket_auth_retry(hass: HomeAssistant) -> None:
"""Test starting a flow by user for not supported device."""
with (
@ -568,7 +570,9 @@ async def test_ssdp_legacy_not_supported(hass: HomeAssistant) -> None:
assert result["reason"] == RESULT_NOT_SUPPORTED
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_ssdp_websocket_success_populates_mac_address_and_ssdp_location(
hass: HomeAssistant,
) -> None:
@ -597,7 +601,9 @@ async def test_ssdp_websocket_success_populates_mac_address_and_ssdp_location(
assert result["result"].unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_ssdp_websocket_success_populates_mac_address_and_main_tv_ssdp_location(
hass: HomeAssistant,
) -> None:
@ -626,7 +632,7 @@ async def test_ssdp_websocket_success_populates_mac_address_and_main_tv_ssdp_loc
assert result["result"].unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remoteencws", "rest_api_non_ssl_only")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api_non_ssl_only")
async def test_ssdp_encrypted_websocket_success_populates_mac_address_and_ssdp_location(
hass: HomeAssistant,
) -> None:
@ -737,7 +743,7 @@ async def test_ssdp_wrong_manufacturer(hass: HomeAssistant) -> None:
assert result["reason"] == RESULT_NOT_SUPPORTED
@pytest.mark.usefixtures("remoteencws_failing")
@pytest.mark.usefixtures("remote_encrypted_websocket_failing")
async def test_ssdp_not_successful(hass: HomeAssistant) -> None:
"""Test starting a flow from discovery but no device found."""
with (
@ -769,7 +775,7 @@ async def test_ssdp_not_successful(hass: HomeAssistant) -> None:
assert result["reason"] == RESULT_CANNOT_CONNECT
@pytest.mark.usefixtures("remoteencws_failing")
@pytest.mark.usefixtures("remote_encrypted_websocket_failing")
async def test_ssdp_not_successful_2(hass: HomeAssistant) -> None:
"""Test starting a flow from discovery but no device found."""
with (
@ -801,7 +807,7 @@ async def test_ssdp_not_successful_2(hass: HomeAssistant) -> None:
assert result["reason"] == RESULT_CANNOT_CONNECT
@pytest.mark.usefixtures("remote_legacy", "remoteencws_failing")
@pytest.mark.usefixtures("remote_legacy", "remote_encrypted_websocket_failing")
async def test_ssdp_already_in_progress(hass: HomeAssistant) -> None:
"""Test starting a flow from discovery twice."""
with patch(
@ -823,7 +829,7 @@ async def test_ssdp_already_in_progress(hass: HomeAssistant) -> None:
assert result["reason"] == RESULT_ALREADY_IN_PROGRESS
@pytest.mark.usefixtures("remote_websocket", "remoteencws_failing")
@pytest.mark.usefixtures("remote_websocket", "remote_encrypted_websocket_failing")
async def test_ssdp_already_configured(hass: HomeAssistant) -> None:
"""Test starting a flow from discovery when already configured."""
with patch(
@ -852,7 +858,7 @@ async def test_ssdp_already_configured(hass: HomeAssistant) -> None:
@pytest.mark.usefixtures(
"remote_websocket", "rest_api_non_ssl_only", "remoteencws_failing"
"remote_websocket", "rest_api_non_ssl_only", "remote_encrypted_websocket_failing"
)
async def test_dhcp_wireless(hass: HomeAssistant) -> None:
"""Test starting a flow from dhcp."""
@ -879,7 +885,9 @@ async def test_dhcp_wireless(hass: HomeAssistant) -> None:
assert result["result"].unique_id == "223da676-497a-4e06-9507-5e27ec4f0fb3"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_dhcp_wired(hass: HomeAssistant, rest_api: Mock) -> None:
"""Test starting a flow from dhcp."""
# Even though it is named "wifiMac", it matches the mac of the wired connection
@ -910,7 +918,7 @@ async def test_dhcp_wired(hass: HomeAssistant, rest_api: Mock) -> None:
@pytest.mark.usefixtures(
"remote_websocket", "rest_api_non_ssl_only", "remoteencws_failing"
"remote_websocket", "rest_api_non_ssl_only", "remote_encrypted_websocket_failing"
)
@pytest.mark.parametrize(
("source1", "data1", "source2", "data2", "is_matching_result"),
@ -983,7 +991,9 @@ async def test_dhcp_zeroconf_already_in_progress(
assert return_values == [is_matching_result]
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_zeroconf(hass: HomeAssistant) -> None:
"""Test starting a flow from zeroconf."""
result = await hass.config_entries.flow.async_init(
@ -1008,7 +1018,7 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
assert result["result"].unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "remoteencws_failing")
@pytest.mark.usefixtures("remote_websocket", "remote_encrypted_websocket_failing")
async def test_zeroconf_ignores_soundbar(hass: HomeAssistant, rest_api: Mock) -> None:
"""Test starting a flow from zeroconf where the device is actually a soundbar."""
rest_api.rest_device_info.return_value = {
@ -1032,7 +1042,10 @@ async def test_zeroconf_ignores_soundbar(hass: HomeAssistant, rest_api: Mock) ->
@pytest.mark.usefixtures(
"remote_legacy", "remote_websocket", "remoteencws", "rest_api_failing"
"remote_legacy",
"remote_websocket",
"remote_encrypted_websocket",
"rest_api_failing",
)
async def test_zeroconf_no_device_info(hass: HomeAssistant) -> None:
"""Test starting a flow from zeroconf where device_info returns None."""
@ -1046,7 +1059,9 @@ async def test_zeroconf_no_device_info(hass: HomeAssistant) -> None:
assert result["reason"] == RESULT_NOT_SUPPORTED
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_zeroconf_and_dhcp_same_time(hass: HomeAssistant) -> None:
"""Test starting a flow from zeroconf and dhcp."""
result = await hass.config_entries.flow.async_init(
@ -1068,7 +1083,7 @@ async def test_zeroconf_and_dhcp_same_time(hass: HomeAssistant) -> None:
assert result2["reason"] == "already_in_progress"
@pytest.mark.usefixtures("remoteencws_failing")
@pytest.mark.usefixtures("remote_encrypted_websocket_failing")
async def test_autodetect_websocket(hass: HomeAssistant) -> None:
"""Test for send key with autodetection of protocol."""
with (
@ -1118,7 +1133,7 @@ async def test_autodetect_websocket(hass: HomeAssistant) -> None:
assert entries[0].data[CONF_MAC] == "aa:bb:cc:dd:ee:ff"
@pytest.mark.usefixtures("remoteencws_failing")
@pytest.mark.usefixtures("remote_encrypted_websocket_failing")
async def test_websocket_no_mac(hass: HomeAssistant, mac_address: Mock) -> None:
"""Test for send key with autodetection of protocol."""
mac_address.return_value = "gg:ee:tt:mm:aa:cc"
@ -1250,7 +1265,9 @@ async def test_autodetect_none(hass: HomeAssistant) -> None:
assert rest_device_info.call_count == 2
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_old_entry(hass: HomeAssistant) -> None:
"""Test update of old entry sets unique id."""
entry = MockConfigEntry(domain=DOMAIN, data=ENTRYDATA_LEGACY)
@ -1279,7 +1296,9 @@ async def test_update_old_entry(hass: HomeAssistant) -> None:
assert entry2.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_missing_mac_unique_id_added_from_dhcp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1301,7 +1320,9 @@ async def test_update_missing_mac_unique_id_added_from_dhcp(
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_incorrectly_formatted_mac_unique_id_added_from_dhcp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1325,7 +1346,9 @@ async def test_update_incorrectly_formatted_mac_unique_id_added_from_dhcp(
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_missing_mac_unique_id_added_from_zeroconf(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1376,7 +1399,9 @@ async def test_update_missing_model_added_from_ssdp(
assert entry.data[CONF_MODEL] == "UE55H6400"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_missing_mac_unique_id_ssdp_location_added_from_ssdp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1401,7 +1426,10 @@ async def test_update_missing_mac_unique_id_ssdp_location_added_from_ssdp(
@pytest.mark.usefixtures(
"remote_legacy", "remote_websocket", "remoteencws_failing", "rest_api_failing"
"remote_legacy",
"remote_websocket",
"remote_encrypted_websocket_failing",
"rest_api_failing",
)
async def test_update_zeroconf_discovery_preserved_unique_id(
hass: HomeAssistant,
@ -1425,7 +1453,9 @@ async def test_update_zeroconf_discovery_preserved_unique_id(
assert entry.unique_id == "original"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_missing_mac_unique_id_added_ssdp_location_updated_from_ssdp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1458,7 +1488,9 @@ async def test_update_missing_mac_unique_id_added_ssdp_location_updated_from_ssd
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_missing_mac_unique_id_added_ssdp_location_rendering_st_updated_from_ssdp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1492,7 +1524,9 @@ async def test_update_missing_mac_unique_id_added_ssdp_location_rendering_st_upd
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_missing_mac_unique_id_added_ssdp_location_main_tv_agent_st_updated_from_ssdp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1530,7 +1564,9 @@ async def test_update_missing_mac_unique_id_added_ssdp_location_main_tv_agent_st
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_ssdp_location_rendering_st_updated_from_ssdp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1561,7 +1597,9 @@ async def test_update_ssdp_location_rendering_st_updated_from_ssdp(
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_main_tv_ssdp_location_rendering_st_updated_from_ssdp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1682,7 +1720,9 @@ async def test_update_legacy_missing_mac_from_dhcp_no_unique_id(
assert entry.unique_id is None
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_ssdp_location_unique_id_added_from_ssdp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1710,7 +1750,9 @@ async def test_update_ssdp_location_unique_id_added_from_ssdp(
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_ssdp_location_unique_id_added_from_ssdp_with_rendering_control_st(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1833,10 +1875,10 @@ async def test_form_reauth_websocket_not_supported(hass: HomeAssistant) -> None:
assert result2["reason"] == RESULT_NOT_SUPPORTED
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
async def test_form_reauth_encrypted(hass: HomeAssistant) -> None:
"""Test reauth flow for encrypted TVs."""
encrypted_entry_data = {**MOCK_ENTRYDATA_ENCRYPTED_WS}
encrypted_entry_data = deepcopy(ENTRYDATA_ENCRYPTED_WEBSOCKET)
del encrypted_entry_data[CONF_TOKEN]
del encrypted_entry_data[CONF_SESSION_ID]
@ -1889,7 +1931,7 @@ async def test_form_reauth_encrypted(hass: HomeAssistant) -> None:
assert entry.state is ConfigEntryState.LOADED
authenticator_mock.assert_called_once()
assert authenticator_mock.call_args[0] == ("fake_host",)
assert authenticator_mock.call_args[0] == ("10.10.12.34",)
authenticator_mock.return_value.start_pairing.assert_called_once()
assert authenticator_mock.return_value.try_pin.call_count == 2
@ -1903,7 +1945,9 @@ async def test_form_reauth_encrypted(hass: HomeAssistant) -> None:
assert entry.data[CONF_SESSION_ID] == "1"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_incorrect_udn_matching_upnp_udn_unique_id_added_from_ssdp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1929,7 +1973,9 @@ async def test_update_incorrect_udn_matching_upnp_udn_unique_id_added_from_ssdp(
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_incorrect_udn_matching_mac_unique_id_added_from_ssdp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1955,7 +2001,9 @@ async def test_update_incorrect_udn_matching_mac_unique_id_added_from_ssdp(
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_update_incorrect_udn_matching_mac_from_dhcp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -1982,7 +2030,9 @@ async def test_update_incorrect_udn_matching_mac_from_dhcp(
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remote_websocket", "rest_api", "remoteencws_failing")
@pytest.mark.usefixtures(
"remote_websocket", "rest_api", "remote_encrypted_websocket_failing"
)
async def test_no_update_incorrect_udn_not_matching_mac_from_dhcp(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None:
@ -2009,7 +2059,7 @@ async def test_no_update_incorrect_udn_not_matching_mac_from_dhcp(
assert entry.unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
@pytest.mark.usefixtures("remote_websocket", "remoteencws_failing")
@pytest.mark.usefixtures("remote_websocket", "remote_encrypted_websocket_failing")
async def test_ssdp_update_mac(hass: HomeAssistant) -> None:
"""Ensure that MAC address is correctly updated from SSDP."""
with patch(

View File

@ -16,17 +16,17 @@ from homeassistant.helpers import device_registry as dr
from homeassistant.setup import async_setup_component
from . import setup_samsungtv_entry
from .const import MOCK_ENTRYDATA_ENCRYPTED_WS
from .const import ENTRYDATA_ENCRYPTED_WEBSOCKET
from tests.common import MockConfigEntry, async_get_device_automations
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
async def test_get_triggers(
hass: HomeAssistant, device_registry: dr.DeviceRegistry
) -> None:
"""Test we get the expected triggers."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
device = device_registry.async_get_device(
identifiers={(DOMAIN, "be9554b9-c9fb-41f4-8920-22da015376a4")}
@ -46,14 +46,14 @@ async def test_get_triggers(
assert turn_on_trigger in triggers
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
async def test_if_fires_on_turn_on_request(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
service_calls: list[ServiceCall],
) -> None:
"""Test for turn_on and turn_off triggers firing."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
entity_id = "media_player.mock_title"
device = device_registry.async_get_device(
@ -109,12 +109,12 @@ async def test_if_fires_on_turn_on_request(
assert service_calls[2].data["id"] == 0
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
async def test_failure_scenarios(
hass: HomeAssistant, device_registry: dr.DeviceRegistry
) -> None:
"""Test failure scenarios."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
# Test wrong trigger platform type
with pytest.raises(HomeAssistantError):

View File

@ -11,7 +11,7 @@ from homeassistant.components.samsungtv.const import DOMAIN
from homeassistant.core import HomeAssistant
from . import setup_samsungtv_entry
from .const import MOCK_ENTRY_WS_WITH_MAC, MOCK_ENTRYDATA_ENCRYPTED_WS
from .const import ENTRYDATA_ENCRYPTED_WEBSOCKET, MOCK_ENTRY_WS_WITH_MAC
from tests.common import load_json_object_fixture
from tests.components.diagnostics import get_diagnostics_for_config_entry
@ -32,7 +32,7 @@ async def test_entry_diagnostics(
) == snapshot(exclude=props("created_at", "modified_at"))
@pytest.mark.usefixtures("remoteencws")
@pytest.mark.usefixtures("remote_encrypted_websocket")
async def test_entry_diagnostics_encrypted(
hass: HomeAssistant,
rest_api: Mock,
@ -43,14 +43,14 @@ async def test_entry_diagnostics_encrypted(
rest_api.rest_device_info.return_value = load_json_object_fixture(
"device_info_UE48JU6400.json", DOMAIN
)
config_entry = await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
config_entry = await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
assert await get_diagnostics_for_config_entry(
hass, hass_client, config_entry
) == snapshot(exclude=props("created_at", "modified_at"))
@pytest.mark.usefixtures("remoteencws")
@pytest.mark.usefixtures("remote_encrypted_websocket")
async def test_entry_diagnostics_encrypte_offline(
hass: HomeAssistant,
rest_api: Mock,
@ -59,7 +59,7 @@ async def test_entry_diagnostics_encrypte_offline(
) -> None:
"""Test config entry diagnostics."""
rest_api.rest_device_info.side_effect = HttpApiError
config_entry = await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
config_entry = await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
assert await get_diagnostics_for_config_entry(
hass, hass_client, config_entry

View File

@ -40,9 +40,9 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
from . import setup_samsungtv_entry
from .const import (
ENTRYDATA_ENCRYPTED_WEBSOCKET,
ENTRYDATA_WEBSOCKET,
MOCK_ENTRY_WS_WITH_MAC,
MOCK_ENTRYDATA_ENCRYPTED_WS,
MOCK_SSDP_DATA_MAIN_TV_AGENT_ST,
MOCK_SSDP_DATA_RENDERING_CONTROL_ST,
)
@ -57,7 +57,9 @@ MOCK_CONFIG = {
}
@pytest.mark.usefixtures("remote_websocket", "remoteencws_failing", "rest_api")
@pytest.mark.usefixtures(
"remote_websocket", "remote_encrypted_websocket_failing", "rest_api"
)
async def test_setup(hass: HomeAssistant) -> None:
"""Test Samsung TV integration is setup."""
await setup_samsungtv_entry(hass, MOCK_CONFIG)
@ -101,7 +103,9 @@ async def test_setup_without_port_device_offline(hass: HomeAssistant) -> None:
assert config_entries_domain[0].state is ConfigEntryState.SETUP_RETRY
@pytest.mark.usefixtures("remote_websocket", "remoteencws_failing", "rest_api")
@pytest.mark.usefixtures(
"remote_websocket", "remote_encrypted_websocket_failing", "rest_api"
)
async def test_setup_without_port_device_online(hass: HomeAssistant) -> None:
"""Test import from yaml when the device is online."""
await setup_samsungtv_entry(hass, MOCK_CONFIG)
@ -111,7 +115,7 @@ async def test_setup_without_port_device_online(hass: HomeAssistant) -> None:
assert config_entries_domain[0].data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
@pytest.mark.usefixtures("remote_websocket", "remoteencws_failing")
@pytest.mark.usefixtures("remote_websocket", "remote_encrypted_websocket_failing")
async def test_setup_h_j_model(
hass: HomeAssistant, rest_api: Mock, caplog: pytest.LogCaptureFixture
) -> None:
@ -162,10 +166,10 @@ async def test_setup_updates_from_ssdp(
)
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
async def test_reauth_triggered_encrypted(hass: HomeAssistant) -> None:
"""Test reauth flow is triggered for encrypted TVs."""
encrypted_entry_data = {**MOCK_ENTRYDATA_ENCRYPTED_WS}
encrypted_entry_data = {**ENTRYDATA_ENCRYPTED_WEBSOCKET}
del encrypted_entry_data[CONF_TOKEN]
del encrypted_entry_data[CONF_SESSION_ID]
@ -179,7 +183,9 @@ async def test_reauth_triggered_encrypted(hass: HomeAssistant) -> None:
assert len(flows_in_progress) == 1
@pytest.mark.usefixtures("remote_legacy", "remoteencws_failing", "rest_api_failing")
@pytest.mark.usefixtures(
"remote_legacy", "remote_encrypted_websocket_failing", "rest_api_failing"
)
@pytest.mark.parametrize(
"entry_data",
[

View File

@ -81,9 +81,9 @@ from homeassistant.setup import async_setup_component
from . import setup_samsungtv_entry
from .const import (
ENTRYDATA_ENCRYPTED_WEBSOCKET,
ENTRYDATA_LEGACY,
MOCK_ENTRY_WS_WITH_MAC,
MOCK_ENTRYDATA_ENCRYPTED_WS,
SAMPLE_DEVICE_INFO_WIFI,
)
@ -201,7 +201,7 @@ async def test_setup_encrypted_websocket(
remote.__aexit__ = AsyncMock()
remote_class.return_value = remote
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
freezer.tick(timedelta(minutes=5))
async_fire_time_changed(hass)
@ -342,19 +342,21 @@ async def test_update_off_ws_with_power_state(
async def test_update_off_encryptedws(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
remoteencws: Mock,
remote_encrypted_websocket: Mock,
rest_api: Mock,
) -> None:
"""Testing update tv off."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
rest_api.rest_device_info.assert_called_once()
state = hass.states.get(ENTITY_ID)
assert state.state == STATE_ON
remoteencws.start_listening = Mock(side_effect=WebSocketException("Boom"))
remoteencws.is_alive.return_value = False
remote_encrypted_websocket.start_listening = Mock(
side_effect=WebSocketException("Boom")
)
remote_encrypted_websocket.is_alive.return_value = False
freezer.tick(timedelta(minutes=5))
async_fire_time_changed(hass)
@ -595,11 +597,13 @@ async def test_send_key_websocketexception(
@pytest.mark.usefixtures("rest_api")
async def test_send_key_websocketexception_encrypted(
hass: HomeAssistant, remoteencws: Mock
hass: HomeAssistant, remote_encrypted_websocket: Mock
) -> None:
"""Testing unhandled response exception."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
remoteencws.send_commands = Mock(side_effect=WebSocketException("Boom"))
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
remote_encrypted_websocket.send_commands = Mock(
side_effect=WebSocketException("Boom")
)
await hass.services.async_call(
MP_DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
)
@ -623,11 +627,11 @@ async def test_send_key_os_error_ws(
@pytest.mark.usefixtures("rest_api")
async def test_send_key_os_error_ws_encrypted(
hass: HomeAssistant, remoteencws: Mock
hass: HomeAssistant, remote_encrypted_websocket: Mock
) -> None:
"""Testing unhandled response exception."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
remoteencws.send_commands = Mock(side_effect=OSError("Boom"))
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
remote_encrypted_websocket.send_commands = Mock(side_effect=OSError("Boom"))
await hass.services.async_call(
MP_DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
)
@ -774,36 +778,38 @@ async def test_turn_off_websocket_frame(
async def test_turn_off_encrypted_websocket(
hass: HomeAssistant, remoteencws: Mock, caplog: pytest.LogCaptureFixture
hass: HomeAssistant,
remote_encrypted_websocket: Mock,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test for turn_off."""
entry_data = deepcopy(MOCK_ENTRYDATA_ENCRYPTED_WS)
entry_data = deepcopy(ENTRYDATA_ENCRYPTED_WEBSOCKET)
entry_data[CONF_MODEL] = "UE48UNKNOWN"
await setup_samsungtv_entry(hass, entry_data)
remoteencws.send_commands.reset_mock()
remote_encrypted_websocket.send_commands.reset_mock()
caplog.clear()
await hass.services.async_call(
MP_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
)
# key called
assert remoteencws.send_commands.call_count == 1
commands = remoteencws.send_commands.call_args_list[0].args[0]
assert remote_encrypted_websocket.send_commands.call_count == 1
commands = remote_encrypted_websocket.send_commands.call_args_list[0].args[0]
assert len(commands) == 2
assert isinstance(command := commands[0], SamsungTVEncryptedCommand)
assert command.body["param3"] == "KEY_POWEROFF"
assert isinstance(command := commands[1], SamsungTVEncryptedCommand)
assert command.body["param3"] == "KEY_POWER"
assert "Unknown power_off command for UE48UNKNOWN (fake_host)" in caplog.text
assert "Unknown power_off command for UE48UNKNOWN (10.10.12.34)" in caplog.text
# commands not sent : power off in progress
remoteencws.send_commands.reset_mock()
remote_encrypted_websocket.send_commands.reset_mock()
await hass.services.async_call(
MP_DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
)
assert "TV is powering off, not sending keys: ['KEY_VOLUP']" in caplog.text
remoteencws.send_commands.assert_not_called()
remote_encrypted_websocket.send_commands.assert_not_called()
@pytest.mark.parametrize(
@ -812,25 +818,25 @@ async def test_turn_off_encrypted_websocket(
)
async def test_turn_off_encrypted_websocket_key_type(
hass: HomeAssistant,
remoteencws: Mock,
remote_encrypted_websocket: Mock,
caplog: pytest.LogCaptureFixture,
model: str,
expected_key_type: str,
) -> None:
"""Test for turn_off."""
entry_data = deepcopy(MOCK_ENTRYDATA_ENCRYPTED_WS)
entry_data = deepcopy(ENTRYDATA_ENCRYPTED_WEBSOCKET)
entry_data[CONF_MODEL] = model
await setup_samsungtv_entry(hass, entry_data)
remoteencws.send_commands.reset_mock()
remote_encrypted_websocket.send_commands.reset_mock()
caplog.clear()
await hass.services.async_call(
MP_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
)
# key called
assert remoteencws.send_commands.call_count == 1
commands = remoteencws.send_commands.call_args_list[0].args[0]
assert remote_encrypted_websocket.send_commands.call_count == 1
commands = remote_encrypted_websocket.send_commands.call_args_list[0].args[0]
assert len(commands) == 1
assert isinstance(command := commands[0], SamsungTVEncryptedCommand)
assert command.body["param3"] == expected_key_type
@ -877,12 +883,14 @@ async def test_turn_off_ws_os_error(
@pytest.mark.usefixtures("rest_api")
async def test_turn_off_encryptedws_os_error(
hass: HomeAssistant, remoteencws: Mock, caplog: pytest.LogCaptureFixture
hass: HomeAssistant,
remote_encrypted_websocket: Mock,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test for turn_off with OSError."""
caplog.set_level(logging.DEBUG)
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
remoteencws.close = Mock(side_effect=OSError("BOOM"))
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
remote_encrypted_websocket.close = Mock(side_effect=OSError("BOOM"))
await hass.services.async_call(
MP_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
)

View File

@ -17,39 +17,45 @@ from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_registry as er
from . import setup_samsungtv_entry
from .const import ENTRYDATA_LEGACY, MOCK_ENTRY_WS_WITH_MAC, MOCK_ENTRYDATA_ENCRYPTED_WS
from .const import (
ENTRYDATA_ENCRYPTED_WEBSOCKET,
ENTRYDATA_LEGACY,
MOCK_ENTRY_WS_WITH_MAC,
)
from tests.common import MockConfigEntry
ENTITY_ID = f"{REMOTE_DOMAIN}.mock_title"
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
async def test_setup(hass: HomeAssistant) -> None:
"""Test setup with basic config."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
assert hass.states.get(ENTITY_ID)
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
async def test_unique_id(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test unique id."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
main = entity_registry.async_get(ENTITY_ID)
assert main.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
async def test_main_services(
hass: HomeAssistant, remoteencws: Mock, caplog: pytest.LogCaptureFixture
hass: HomeAssistant,
remote_encrypted_websocket: Mock,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test for turn_off."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
remoteencws.send_commands.reset_mock()
remote_encrypted_websocket.send_commands.reset_mock()
await hass.services.async_call(
REMOTE_DOMAIN,
@ -59,8 +65,8 @@ async def test_main_services(
)
# key called
assert remoteencws.send_commands.call_count == 1
commands = remoteencws.send_commands.call_args_list[0].args[0]
assert remote_encrypted_websocket.send_commands.call_count == 1
commands = remote_encrypted_websocket.send_commands.call_args_list[0].args[0]
assert len(commands) == 2
assert isinstance(command := commands[0], SamsungTVEncryptedCommand)
assert command.body["param3"] == "KEY_POWEROFF"
@ -68,7 +74,7 @@ async def test_main_services(
assert command.body["param3"] == "KEY_POWER"
# commands not sent : power off in progress
remoteencws.send_commands.reset_mock()
remote_encrypted_websocket.send_commands.reset_mock()
await hass.services.async_call(
REMOTE_DOMAIN,
SERVICE_SEND_COMMAND,
@ -76,13 +82,15 @@ async def test_main_services(
blocking=True,
)
assert "TV is powering off, not sending keys: ['dash']" in caplog.text
remoteencws.send_commands.assert_not_called()
remote_encrypted_websocket.send_commands.assert_not_called()
@pytest.mark.usefixtures("remoteencws", "rest_api")
async def test_send_command_service(hass: HomeAssistant, remoteencws: Mock) -> None:
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
async def test_send_command_service(
hass: HomeAssistant, remote_encrypted_websocket: Mock
) -> None:
"""Test the send command."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
await hass.services.async_call(
REMOTE_DOMAIN,
@ -91,8 +99,8 @@ async def test_send_command_service(hass: HomeAssistant, remoteencws: Mock) -> N
blocking=True,
)
assert remoteencws.send_commands.call_count == 1
commands = remoteencws.send_commands.call_args_list[0].args[0]
assert remote_encrypted_websocket.send_commands.call_count == 1
commands = remote_encrypted_websocket.send_commands.call_args_list[0].args[0]
assert len(commands) == 1
assert isinstance(command := commands[0], SamsungTVEncryptedCommand)
assert command.body["param3"] == "dash"

View File

@ -12,12 +12,12 @@ from homeassistant.helpers import device_registry as dr
from homeassistant.setup import async_setup_component
from . import setup_samsungtv_entry
from .const import MOCK_ENTRYDATA_ENCRYPTED_WS
from .const import ENTRYDATA_ENCRYPTED_WEBSOCKET
from tests.common import MockEntity, MockEntityPlatform
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
@pytest.mark.parametrize("entity_domain", ["media_player", "remote"])
async def test_turn_on_trigger_device_id(
hass: HomeAssistant,
@ -26,7 +26,7 @@ async def test_turn_on_trigger_device_id(
entity_domain: str,
) -> None:
"""Test for turn_on triggers by device_id firing."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
entity_id = f"{entity_domain}.mock_title"
@ -84,13 +84,13 @@ async def test_turn_on_trigger_device_id(
mock_send_magic_packet.assert_called()
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
@pytest.mark.parametrize("entity_domain", ["media_player", "remote"])
async def test_turn_on_trigger_entity_id(
hass: HomeAssistant, service_calls: list[ServiceCall], entity_domain: str
) -> None:
"""Test for turn_on triggers by entity_id firing."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
entity_id = f"{entity_domain}.mock_title"
@ -126,13 +126,13 @@ async def test_turn_on_trigger_entity_id(
assert service_calls[1].data["id"] == 0
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
@pytest.mark.parametrize("entity_domain", ["media_player", "remote"])
async def test_wrong_trigger_platform_type(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, entity_domain: str
) -> None:
"""Test wrong trigger platform type."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
entity_id = f"{entity_domain}.fake"
await async_setup_component(
@ -163,13 +163,13 @@ async def test_wrong_trigger_platform_type(
)
@pytest.mark.usefixtures("remoteencws", "rest_api")
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")
@pytest.mark.parametrize("entity_domain", ["media_player", "remote"])
async def test_trigger_invalid_entity_id(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, entity_domain: str
) -> None:
"""Test turn on trigger using invalid entity_id."""
await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS)
await setup_samsungtv_entry(hass, ENTRYDATA_ENCRYPTED_WEBSOCKET)
entity_id = f"{entity_domain}.fake"
platform = MockEntityPlatform(hass)