From fca62f1ae8241c14588861e1f7f73e1217058740 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 2 May 2025 08:32:44 +0200 Subject: [PATCH] Move SamsungTV test constants to fixture files (#144086) --- tests/components/samsungtv/conftest.py | 8 +- tests/components/samsungtv/const.py | 101 ------------- .../fixtures/device_info_UE43LS003.json | 34 +++++ .../fixtures/device_info_UE48JU6400.json | 28 ++++ .../fixtures/ws_installed_app_event.json | 29 ++++ .../samsungtv/snapshots/test_diagnostics.ambr | 137 ++++++++++++++++++ .../components/samsungtv/test_config_flow.py | 7 +- .../components/samsungtv/test_diagnostics.py | 131 ++++------------- tests/components/samsungtv/test_init.py | 7 +- .../components/samsungtv/test_media_player.py | 20 ++- 10 files changed, 283 insertions(+), 219 deletions(-) create mode 100644 tests/components/samsungtv/fixtures/device_info_UE43LS003.json create mode 100644 tests/components/samsungtv/fixtures/device_info_UE48JU6400.json create mode 100644 tests/components/samsungtv/fixtures/ws_installed_app_event.json create mode 100644 tests/components/samsungtv/snapshots/test_diagnostics.ambr diff --git a/tests/components/samsungtv/conftest.py b/tests/components/samsungtv/conftest.py index 4b3ad59defd..c33fd89ec56 100644 --- a/tests/components/samsungtv/conftest.py +++ b/tests/components/samsungtv/conftest.py @@ -19,9 +19,11 @@ from samsungtvws.event import ED_INSTALLED_APP_EVENT from samsungtvws.exceptions import ResponseError from samsungtvws.remote import ChannelEmitCommand -from homeassistant.components.samsungtv.const import WEBSOCKET_SSL_PORT +from homeassistant.components.samsungtv.const import DOMAIN, WEBSOCKET_SSL_PORT -from .const import SAMPLE_DEVICE_INFO_UE48JU6400, SAMPLE_DEVICE_INFO_WIFI +from .const import SAMPLE_DEVICE_INFO_WIFI + +from tests.common import load_json_object_fixture @pytest.fixture @@ -186,7 +188,7 @@ def rest_api_fixture_non_ssl_only() -> Generator[None]: """Mock rest_device_info to fail for ssl and work for non-ssl.""" if self.port == WEBSOCKET_SSL_PORT: raise ResponseError - return SAMPLE_DEVICE_INFO_UE48JU6400 + return load_json_object_fixture("device_info_UE48JU6400.json", DOMAIN) with patch( "homeassistant.components.samsungtv.bridge.SamsungTVAsyncRest", diff --git a/tests/components/samsungtv/const.py b/tests/components/samsungtv/const.py index c1a9da4e284..5d09087dadd 100644 --- a/tests/components/samsungtv/const.py +++ b/tests/components/samsungtv/const.py @@ -1,7 +1,5 @@ """Constants for the samsungtv tests.""" -from samsungtvws.event import ED_INSTALLED_APP_EVENT - from homeassistant.components.samsungtv.const import ( CONF_SESSION_ID, METHOD_LEGACY, @@ -94,102 +92,3 @@ SAMPLE_DEVICE_INFO_WIFI = { "networkType": "wireless", }, } - -SAMPLE_DEVICE_INFO_FRAME = { - "device": { - "FrameTVSupport": "true", - "GamePadSupport": "true", - "ImeSyncedSupport": "true", - "OS": "Tizen", - "TokenAuthSupport": "true", - "VoiceSupport": "true", - "countryCode": "FR", - "description": "Samsung DTV RCR", - "developerIP": "0.0.0.0", - "developerMode": "0", - "duid": "uuid:be9554b9-c9fb-41f4-8920-22da015376a4", - "firmwareVersion": "Unknown", - "id": "uuid:be9554b9-c9fb-41f4-8920-22da015376a4", - "ip": "1.2.3.4", - "model": "17_KANTM_UHD", - "modelName": "UE43LS003", - "name": "[TV] Samsung Frame (43)", - "networkType": "wired", - "resolution": "3840x2160", - "smartHubAgreement": "true", - "type": "Samsung SmartTV", - "udn": "uuid:be9554b9-c9fb-41f4-8920-22da015376a4", - "wifiMac": "aa:ee:tt:hh:ee:rr", - }, - "id": "uuid:be9554b9-c9fb-41f4-8920-22da015376a4", - "isSupport": ( - '{"DMP_DRM_PLAYREADY":"false","DMP_DRM_WIDEVINE":"false","DMP_available":"true",' - '"EDEN_available":"true","FrameTVSupport":"true","ImeSyncedSupport":"true",' - '"TokenAuthSupport":"true","remote_available":"true","remote_fourDirections":"true",' - '"remote_touchPad":"true","remote_voiceControl":"true"}\n' - ), - "name": "[TV] Samsung Frame (43)", - "remote": "1.0", - "type": "Samsung SmartTV", - "uri": "https://1.2.3.4:8002/api/v2/", - "version": "2.0.25", -} - -SAMPLE_DEVICE_INFO_UE48JU6400 = { - "id": "uuid:223da676-497a-4e06-9507-5e27ec4f0fb3", - "name": "[TV] TV-UE48JU6470", - "version": "2.0.25", - "device": { - "type": "Samsung SmartTV", - "duid": "uuid:223da676-497a-4e06-9507-5e27ec4f0fb3", - "model": "15_HAWKM_UHD_2D", - "modelName": "UE48JU6400", - "description": "Samsung DTV RCR", - "networkType": "wired", - "ssid": "", - "ip": "1.2.3.4", - "firmwareVersion": "Unknown", - "name": "[TV] TV-UE48JU6470", - "id": "uuid:223da676-497a-4e06-9507-5e27ec4f0fb3", - "udn": "uuid:223da676-497a-4e06-9507-5e27ec4f0fb3", - "resolution": "1920x1080", - "countryCode": "AT", - "msfVersion": "2.0.25", - "smartHubAgreement": "true", - "wifiMac": "aa:bb:aa:aa:aa:aa", - "developerMode": "0", - "developerIP": "", - }, - "type": "Samsung SmartTV", - "uri": "https://1.2.3.4:8002/api/v2/", -} - -SAMPLE_EVENT_ED_INSTALLED_APP = { - "event": ED_INSTALLED_APP_EVENT, - "from": "host", - "data": { - "data": [ - { - "appId": "111299001912", - "app_type": 2, - "icon": "/opt/share/webappservice/apps_icon/FirstScreen/111299001912/250x250.png", - "is_lock": 0, - "name": "YouTube", - }, - { - "appId": "3201608010191", - "app_type": 2, - "icon": "/opt/share/webappservice/apps_icon/FirstScreen/3201608010191/250x250.png", - "is_lock": 0, - "name": "Deezer", - }, - { - "appId": "3201606009684", - "app_type": 2, - "icon": "/opt/share/webappservice/apps_icon/FirstScreen/3201606009684/250x250.png", - "is_lock": 0, - "name": "Spotify - Music and Podcasts", - }, - ] - }, -} diff --git a/tests/components/samsungtv/fixtures/device_info_UE43LS003.json b/tests/components/samsungtv/fixtures/device_info_UE43LS003.json new file mode 100644 index 00000000000..ac961fafd6b --- /dev/null +++ b/tests/components/samsungtv/fixtures/device_info_UE43LS003.json @@ -0,0 +1,34 @@ +{ + "device": { + "FrameTVSupport": "true", + "GamePadSupport": "true", + "ImeSyncedSupport": "true", + "OS": "Tizen", + "TokenAuthSupport": "true", + "VoiceSupport": "true", + "countryCode": "FR", + "description": "Samsung DTV RCR", + "developerIP": "0.0.0.0", + "developerMode": "0", + "duid": "uuid:be9554b9-c9fb-41f4-8920-22da015376a4", + "firmwareVersion": "Unknown", + "id": "uuid:be9554b9-c9fb-41f4-8920-22da015376a4", + "ip": "1.2.3.4", + "model": "17_KANTM_UHD", + "modelName": "UE43LS003", + "name": "[TV] Samsung Frame (43)", + "networkType": "wired", + "resolution": "3840x2160", + "smartHubAgreement": "true", + "type": "Samsung SmartTV", + "udn": "uuid:be9554b9-c9fb-41f4-8920-22da015376a4", + "wifiMac": "aa:ee:tt:hh:ee:rr" + }, + "id": "uuid:be9554b9-c9fb-41f4-8920-22da015376a4", + "isSupport": "{\"DMP_DRM_PLAYREADY\":\"false\",\"DMP_DRM_WIDEVINE\":\"false\",\"DMP_available\":\"true\",\"EDEN_available\":\"true\",\"FrameTVSupport\":\"true\",\"ImeSyncedSupport\":\"true\",\"TokenAuthSupport\":\"true\",\"remote_available\":\"true\",\"remote_fourDirections\":\"true\",\"remote_touchPad\":\"true\",\"remote_voiceControl\":\"true\"}\n", + "name": "[TV] Samsung Frame (43)", + "remote": "1.0", + "type": "Samsung SmartTV", + "uri": "https://1.2.3.4:8002/api/v2/", + "version": "2.0.25" +} diff --git a/tests/components/samsungtv/fixtures/device_info_UE48JU6400.json b/tests/components/samsungtv/fixtures/device_info_UE48JU6400.json new file mode 100644 index 00000000000..65cecf095a2 --- /dev/null +++ b/tests/components/samsungtv/fixtures/device_info_UE48JU6400.json @@ -0,0 +1,28 @@ +{ + "id": "uuid:223da676-497a-4e06-9507-5e27ec4f0fb3", + "name": "[TV] TV-UE48JU6470", + "version": "2.0.25", + "device": { + "type": "Samsung SmartTV", + "duid": "uuid:223da676-497a-4e06-9507-5e27ec4f0fb3", + "model": "15_HAWKM_UHD_2D", + "modelName": "UE48JU6400", + "description": "Samsung DTV RCR", + "networkType": "wired", + "ssid": "", + "ip": "1.2.3.4", + "firmwareVersion": "Unknown", + "name": "[TV] TV-UE48JU6470", + "id": "uuid:223da676-497a-4e06-9507-5e27ec4f0fb3", + "udn": "uuid:223da676-497a-4e06-9507-5e27ec4f0fb3", + "resolution": "1920x1080", + "countryCode": "AT", + "msfVersion": "2.0.25", + "smartHubAgreement": "true", + "wifiMac": "aa:bb:aa:aa:aa:aa", + "developerMode": "0", + "developerIP": "" + }, + "type": "Samsung SmartTV", + "uri": "https://1.2.3.4:8002/api/v2/" +} diff --git a/tests/components/samsungtv/fixtures/ws_installed_app_event.json b/tests/components/samsungtv/fixtures/ws_installed_app_event.json new file mode 100644 index 00000000000..81c64f60958 --- /dev/null +++ b/tests/components/samsungtv/fixtures/ws_installed_app_event.json @@ -0,0 +1,29 @@ +{ + "event": "ed.installedApp.get", + "from": "host", + "data": { + "data": [ + { + "appId": "111299001912", + "app_type": 2, + "icon": "/opt/share/webappservice/apps_icon/FirstScreen/111299001912/250x250.png", + "is_lock": 0, + "name": "YouTube" + }, + { + "appId": "3201608010191", + "app_type": 2, + "icon": "/opt/share/webappservice/apps_icon/FirstScreen/3201608010191/250x250.png", + "is_lock": 0, + "name": "Deezer" + }, + { + "appId": "3201606009684", + "app_type": 2, + "icon": "/opt/share/webappservice/apps_icon/FirstScreen/3201606009684/250x250.png", + "is_lock": 0, + "name": "Spotify - Music and Podcasts" + } + ] + } +} diff --git a/tests/components/samsungtv/snapshots/test_diagnostics.ambr b/tests/components/samsungtv/snapshots/test_diagnostics.ambr new file mode 100644 index 00000000000..dd1b3654186 --- /dev/null +++ b/tests/components/samsungtv/snapshots/test_diagnostics.ambr @@ -0,0 +1,137 @@ +# serializer version: 1 +# name: test_entry_diagnostics + dict({ + 'device_info': dict({ + 'device': dict({ + 'modelName': '82GXARRS', + 'name': '[TV] Living Room', + 'networkType': 'wireless', + 'type': 'Samsung SmartTV', + 'wifiMac': 'aa:bb:aa:aa:aa:aa', + }), + 'id': 'uuid:be9554b9-c9fb-41f4-8920-22da015376a4', + }), + 'entry': dict({ + 'data': dict({ + 'host': 'fake_host', + 'ip_address': 'test', + 'mac': 'aa:bb:cc:dd:ee:ff', + 'method': 'websocket', + 'model': '82GXARRS', + 'name': 'fake', + 'port': 8002, + 'token': '**REDACTED**', + }), + 'disabled_by': None, + 'discovery_keys': dict({ + }), + 'domain': 'samsungtv', + 'entry_id': '123456', + 'minor_version': 2, + 'options': dict({ + }), + 'pref_disable_new_entities': False, + 'pref_disable_polling': False, + 'source': 'user', + 'subentries': list([ + ]), + 'title': 'Mock Title', + 'unique_id': 'be9554b9-c9fb-41f4-8920-22da015376a4', + 'version': 2, + }), + }) +# --- +# name: test_entry_diagnostics_encrypte_offline + dict({ + 'device_info': None, + 'entry': dict({ + 'data': dict({ + 'host': 'fake_host', + 'ip_address': 'test', + 'mac': 'aa:bb:cc:dd:ee:ff', + 'method': 'encrypted', + 'name': 'fake', + 'port': 8000, + 'session_id': '**REDACTED**', + 'token': '**REDACTED**', + }), + 'disabled_by': None, + 'discovery_keys': dict({ + }), + 'domain': 'samsungtv', + 'entry_id': '123456', + 'minor_version': 2, + 'options': dict({ + }), + 'pref_disable_new_entities': False, + 'pref_disable_polling': False, + 'source': 'user', + 'subentries': list([ + ]), + 'title': 'Mock Title', + 'unique_id': 'be9554b9-c9fb-41f4-8920-22da015376a4', + 'version': 2, + }), + }) +# --- +# name: test_entry_diagnostics_encrypted + dict({ + 'device_info': dict({ + 'device': dict({ + 'countryCode': 'AT', + 'description': 'Samsung DTV RCR', + 'developerIP': '', + 'developerMode': '0', + 'duid': 'uuid:223da676-497a-4e06-9507-5e27ec4f0fb3', + 'firmwareVersion': 'Unknown', + 'id': 'uuid:223da676-497a-4e06-9507-5e27ec4f0fb3', + 'ip': '1.2.3.4', + 'model': '15_HAWKM_UHD_2D', + 'modelName': 'UE48JU6400', + 'msfVersion': '2.0.25', + 'name': '[TV] TV-UE48JU6470', + 'networkType': 'wired', + 'resolution': '1920x1080', + 'smartHubAgreement': 'true', + 'ssid': '', + 'type': 'Samsung SmartTV', + 'udn': 'uuid:223da676-497a-4e06-9507-5e27ec4f0fb3', + 'wifiMac': 'aa:bb:aa:aa:aa:aa', + }), + 'id': 'uuid:223da676-497a-4e06-9507-5e27ec4f0fb3', + 'name': '[TV] TV-UE48JU6470', + 'type': 'Samsung SmartTV', + 'uri': 'https://1.2.3.4:8002/api/v2/', + 'version': '2.0.25', + }), + 'entry': dict({ + 'data': dict({ + 'host': 'fake_host', + 'ip_address': 'test', + 'mac': 'aa:bb:cc:dd:ee:ff', + 'method': 'encrypted', + 'model': 'UE48JU6400', + 'name': 'fake', + 'port': 8000, + 'session_id': '**REDACTED**', + 'token': '**REDACTED**', + }), + 'disabled_by': None, + 'discovery_keys': dict({ + }), + 'domain': 'samsungtv', + 'entry_id': '123456', + 'minor_version': 2, + 'options': dict({ + }), + 'pref_disable_new_entities': False, + 'pref_disable_polling': False, + 'source': 'user', + 'subentries': list([ + ]), + 'title': 'Mock Title', + 'unique_id': 'be9554b9-c9fb-41f4-8920-22da015376a4', + 'version': 2, + }), + }) +# --- diff --git a/tests/components/samsungtv/test_config_flow.py b/tests/components/samsungtv/test_config_flow.py index 5ff259c2120..12c222033e0 100644 --- a/tests/components/samsungtv/test_config_flow.py +++ b/tests/components/samsungtv/test_config_flow.py @@ -63,10 +63,9 @@ from .const import ( MOCK_ENTRYDATA_WS, MOCK_SSDP_DATA_MAIN_TV_AGENT_ST, MOCK_SSDP_DATA_RENDERING_CONTROL_ST, - SAMPLE_DEVICE_INFO_FRAME, ) -from tests.common import MockConfigEntry +from tests.common import MockConfigEntry, load_json_object_fixture RESULT_ALREADY_CONFIGURED = "already_configured" RESULT_ALREADY_IN_PROGRESS = "already_in_progress" @@ -956,7 +955,9 @@ async def test_dhcp_wireless(hass: HomeAssistant) -> None: 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 - rest_api.rest_device_info.return_value = SAMPLE_DEVICE_INFO_FRAME + rest_api.rest_device_info.return_value = load_json_object_fixture( + "device_info_UE43LS003.json", DOMAIN + ) # confirm to add the entry result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/samsungtv/test_diagnostics.py b/tests/components/samsungtv/test_diagnostics.py index 53d52456de5..3f40c51d5d0 100644 --- a/tests/components/samsungtv/test_diagnostics.py +++ b/tests/components/samsungtv/test_diagnostics.py @@ -4,138 +4,63 @@ from unittest.mock import Mock import pytest from samsungtvws.exceptions import HttpApiError +from syrupy.assertion import SnapshotAssertion +from syrupy.filters import props -from homeassistant.components.diagnostics import REDACTED +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, - SAMPLE_DEVICE_INFO_UE48JU6400, - SAMPLE_DEVICE_INFO_WIFI, -) +from .const import MOCK_ENTRY_WS_WITH_MAC, MOCK_ENTRYDATA_ENCRYPTED_WS -from tests.common import ANY +from tests.common import load_json_object_fixture from tests.components.diagnostics import get_diagnostics_for_config_entry from tests.typing import ClientSessionGenerator @pytest.mark.usefixtures("remotews", "rest_api") async def test_entry_diagnostics( - hass: HomeAssistant, hass_client: ClientSessionGenerator + hass: HomeAssistant, + hass_client: ClientSessionGenerator, + snapshot: SnapshotAssertion, ) -> None: """Test config entry diagnostics.""" config_entry = await setup_samsungtv_entry(hass, MOCK_ENTRY_WS_WITH_MAC) - assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == { - "entry": { - "created_at": ANY, - "data": { - "host": "fake_host", - "ip_address": "test", - "mac": "aa:bb:cc:dd:ee:ff", - "method": "websocket", - "model": "82GXARRS", - "name": "fake", - "port": 8002, - "token": REDACTED, - }, - "disabled_by": None, - "discovery_keys": {}, - "domain": "samsungtv", - "entry_id": "123456", - "minor_version": 2, - "modified_at": ANY, - "options": {}, - "pref_disable_new_entities": False, - "pref_disable_polling": False, - "source": "user", - "subentries": [], - "title": "Mock Title", - "unique_id": "be9554b9-c9fb-41f4-8920-22da015376a4", - "version": 2, - }, - "device_info": SAMPLE_DEVICE_INFO_WIFI, - } + assert await get_diagnostics_for_config_entry( + hass, hass_client, config_entry + ) == snapshot(exclude=props("created_at", "modified_at")) @pytest.mark.usefixtures("remoteencws") async def test_entry_diagnostics_encrypted( - hass: HomeAssistant, rest_api: Mock, hass_client: ClientSessionGenerator + hass: HomeAssistant, + rest_api: Mock, + hass_client: ClientSessionGenerator, + snapshot: SnapshotAssertion, ) -> None: """Test config entry diagnostics.""" - rest_api.rest_device_info.return_value = SAMPLE_DEVICE_INFO_UE48JU6400 + 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) - assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == { - "entry": { - "created_at": ANY, - "data": { - "host": "fake_host", - "ip_address": "test", - "mac": "aa:bb:cc:dd:ee:ff", - "method": "encrypted", - "model": "UE48JU6400", - "name": "fake", - "port": 8000, - "token": REDACTED, - "session_id": REDACTED, - }, - "disabled_by": None, - "discovery_keys": {}, - "domain": "samsungtv", - "entry_id": "123456", - "minor_version": 2, - "modified_at": ANY, - "options": {}, - "pref_disable_new_entities": False, - "pref_disable_polling": False, - "source": "user", - "subentries": [], - "title": "Mock Title", - "unique_id": "be9554b9-c9fb-41f4-8920-22da015376a4", - "version": 2, - }, - "device_info": SAMPLE_DEVICE_INFO_UE48JU6400, - } + assert await get_diagnostics_for_config_entry( + hass, hass_client, config_entry + ) == snapshot(exclude=props("created_at", "modified_at")) @pytest.mark.usefixtures("remoteencws") async def test_entry_diagnostics_encrypte_offline( - hass: HomeAssistant, rest_api: Mock, hass_client: ClientSessionGenerator + hass: HomeAssistant, + rest_api: Mock, + hass_client: ClientSessionGenerator, + snapshot: SnapshotAssertion, ) -> None: """Test config entry diagnostics.""" rest_api.rest_device_info.side_effect = HttpApiError config_entry = await setup_samsungtv_entry(hass, MOCK_ENTRYDATA_ENCRYPTED_WS) - assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == { - "entry": { - "created_at": ANY, - "data": { - "host": "fake_host", - "ip_address": "test", - "mac": "aa:bb:cc:dd:ee:ff", - "method": "encrypted", - "name": "fake", - "port": 8000, - "token": REDACTED, - "session_id": REDACTED, - }, - "disabled_by": None, - "discovery_keys": {}, - "domain": "samsungtv", - "entry_id": "123456", - "minor_version": 2, - "modified_at": ANY, - "options": {}, - "pref_disable_new_entities": False, - "pref_disable_polling": False, - "source": "user", - "subentries": [], - "title": "Mock Title", - "unique_id": "be9554b9-c9fb-41f4-8920-22da015376a4", - "version": 2, - }, - "device_info": None, - } + assert await get_diagnostics_for_config_entry( + hass, hass_client, config_entry + ) == snapshot(exclude=props("created_at", "modified_at")) diff --git a/tests/components/samsungtv/test_init.py b/tests/components/samsungtv/test_init.py index 9f1efc0f013..59dbfad0552 100644 --- a/tests/components/samsungtv/test_init.py +++ b/tests/components/samsungtv/test_init.py @@ -45,10 +45,9 @@ from .const import ( MOCK_ENTRYDATA_WS, MOCK_SSDP_DATA_MAIN_TV_AGENT_ST, MOCK_SSDP_DATA_RENDERING_CONTROL_ST, - SAMPLE_DEVICE_INFO_UE48JU6400, ) -from tests.common import MockConfigEntry +from tests.common import MockConfigEntry, load_json_object_fixture ENTITY_ID = f"{MP_DOMAIN}.fake_name" MOCK_CONFIG = { @@ -117,7 +116,9 @@ async def test_setup_h_j_model( hass: HomeAssistant, rest_api: Mock, caplog: pytest.LogCaptureFixture ) -> None: """Test Samsung TV integration is setup.""" - rest_api.rest_device_info.return_value = SAMPLE_DEVICE_INFO_UE48JU6400 + rest_api.rest_device_info.return_value = load_json_object_fixture( + "device_info_UE48JU6400.json", DOMAIN + ) await setup_samsungtv_entry(hass, MOCK_CONFIG) await hass.async_block_till_done() state = hass.states.get(ENTITY_ID) diff --git a/tests/components/samsungtv/test_media_player.py b/tests/components/samsungtv/test_media_player.py index 10e5249aac3..0a4587827d1 100644 --- a/tests/components/samsungtv/test_media_player.py +++ b/tests/components/samsungtv/test_media_player.py @@ -85,12 +85,14 @@ from .const import ( MOCK_CONFIG, MOCK_ENTRY_WS_WITH_MAC, MOCK_ENTRYDATA_ENCRYPTED_WS, - SAMPLE_DEVICE_INFO_FRAME, SAMPLE_DEVICE_INFO_WIFI, - SAMPLE_EVENT_ED_INSTALLED_APP, ) -from tests.common import MockConfigEntry, async_fire_time_changed +from tests.common import ( + MockConfigEntry, + async_fire_time_changed, + load_json_object_fixture, +) ENTITY_ID = f"{MP_DOMAIN}.fake" MOCK_CONFIGWS = { @@ -689,7 +691,9 @@ async def test_turn_off_websocket( hass: HomeAssistant, remotews: Mock, caplog: pytest.LogCaptureFixture ) -> None: """Test for turn_off.""" - remotews.app_list_data = SAMPLE_EVENT_ED_INSTALLED_APP + remotews.app_list_data = load_json_object_fixture( + "ws_installed_app_event.json", DOMAIN + ) with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[OSError("Boom"), DEFAULT_MOCK], @@ -728,7 +732,9 @@ async def test_turn_off_websocket_frame( hass: HomeAssistant, remotews: Mock, rest_api: Mock ) -> None: """Test for turn_off.""" - rest_api.rest_device_info.return_value = SAMPLE_DEVICE_INFO_FRAME + rest_api.rest_device_info.return_value = load_json_object_fixture( + "device_info_UE43LS003.json", DOMAIN + ) with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[OSError("Boom"), DEFAULT_MOCK], @@ -1136,7 +1142,9 @@ async def test_play_media_app(hass: HomeAssistant, remotews: Mock) -> None: @pytest.mark.usefixtures("rest_api") async def test_select_source_app(hass: HomeAssistant, remotews: Mock) -> None: """Test for select_source.""" - remotews.app_list_data = SAMPLE_EVENT_ED_INSTALLED_APP + remotews.app_list_data = load_json_object_fixture( + "ws_installed_app_event.json", DOMAIN + ) await setup_samsungtv_entry(hass, MOCK_CONFIGWS) remotews.send_commands.reset_mock()