diff --git a/tests/components/roku/fixtures/roku3-diagnostics-data.json b/tests/components/roku/fixtures/roku3-diagnostics-data.json deleted file mode 100644 index a3084b010c9..00000000000 --- a/tests/components/roku/fixtures/roku3-diagnostics-data.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "app": { - "app_id": null, - "name": "Roku", - "screensaver": false, - "version": null - }, - "apps": [ - { - "app_id": "11", - "name": "Roku Channel Store", - "screensaver": false, - "version": null - }, - { - "app_id": "12", - "name": "Netflix", - "screensaver": false, - "version": null - }, - { - "app_id": "13", - "name": "Amazon Video on Demand", - "screensaver": false, - "version": null - }, - { - "app_id": "14", - "name": "MLB.TV®", - "screensaver": false, - "version": null - }, - { - "app_id": "26", - "name": "Free FrameChannel Service", - "screensaver": false, - "version": null - }, - { - "app_id": "27", - "name": "Mediafly", - "screensaver": false, - "version": null - }, - { - "app_id": "28", - "name": "Pandora", - "screensaver": false, - "version": null - }, - { - "app_id": "74519", - "name": "Pluto TV - It's Free TV", - "screensaver": false, - "version": "5.2.0" - } - ], - "channel": null, - "channels": [], - "info": { - "brand": "Roku", - "device_location": null, - "device_type": "box", - "ethernet_mac": "b0:a7:37:96:4d:fa", - "ethernet_support": true, - "headphones_connected": false, - "model_name": "Roku 3", - "model_number": "4200X", - "name": "My Roku 3", - "network_name": null, - "network_type": "ethernet", - "serial_number": "1GU48T017973", - "supports_airplay": false, - "supports_find_remote": false, - "supports_private_listening": false, - "supports_wake_on_wlan": false, - "version": "7.5.0", - "wifi_mac": "b0:a7:37:96:4d:fb" - }, - "media": null, - "state": { - "at": "2022-01-23T21:05:03.154737", - "available": true, - "standby": false - } -} diff --git a/tests/components/roku/snapshots/test_diagnostics.ambr b/tests/components/roku/snapshots/test_diagnostics.ambr new file mode 100644 index 00000000000..1742d1f7ee0 --- /dev/null +++ b/tests/components/roku/snapshots/test_diagnostics.ambr @@ -0,0 +1,98 @@ +# serializer version: 1 +# name: test_diagnostics + dict({ + 'data': dict({ + 'app': dict({ + 'app_id': None, + 'name': 'Roku', + 'screensaver': False, + 'version': None, + }), + 'apps': list([ + dict({ + 'app_id': '11', + 'name': 'Roku Channel Store', + 'screensaver': False, + 'version': None, + }), + dict({ + 'app_id': '12', + 'name': 'Netflix', + 'screensaver': False, + 'version': None, + }), + dict({ + 'app_id': '13', + 'name': 'Amazon Video on Demand', + 'screensaver': False, + 'version': None, + }), + dict({ + 'app_id': '14', + 'name': 'MLB.TV®', + 'screensaver': False, + 'version': None, + }), + dict({ + 'app_id': '26', + 'name': 'Free FrameChannel Service', + 'screensaver': False, + 'version': None, + }), + dict({ + 'app_id': '27', + 'name': 'Mediafly', + 'screensaver': False, + 'version': None, + }), + dict({ + 'app_id': '28', + 'name': 'Pandora', + 'screensaver': False, + 'version': None, + }), + dict({ + 'app_id': '74519', + 'name': "Pluto TV - It's Free TV", + 'screensaver': False, + 'version': '5.2.0', + }), + ]), + 'channel': None, + 'channels': list([ + ]), + 'info': dict({ + 'brand': 'Roku', + 'device_location': None, + 'device_type': 'box', + 'ethernet_mac': 'b0:a7:37:96:4d:fa', + 'ethernet_support': True, + 'headphones_connected': False, + 'model_name': 'Roku 3', + 'model_number': '4200X', + 'name': 'My Roku 3', + 'network_name': None, + 'network_type': 'ethernet', + 'serial_number': '1GU48T017973', + 'supports_airplay': False, + 'supports_find_remote': False, + 'supports_private_listening': False, + 'supports_wake_on_wlan': False, + 'version': '7.5.0', + 'wifi_mac': 'b0:a7:37:96:4d:fb', + }), + 'media': None, + 'state': dict({ + 'at': '2023-08-15T17:00:00+00:00', + 'available': True, + 'standby': False, + }), + }), + 'entry': dict({ + 'data': dict({ + 'host': '192.168.1.160', + }), + 'unique_id': '1GU48T017973', + }), + }) +# --- diff --git a/tests/components/roku/test_diagnostics.py b/tests/components/roku/test_diagnostics.py index 860d0424624..708e6d3f5e3 100644 --- a/tests/components/roku/test_diagnostics.py +++ b/tests/components/roku/test_diagnostics.py @@ -1,9 +1,11 @@ """Tests for the diagnostics data provided by the Roku integration.""" -import json +from rokuecp import Device as RokuDevice +from syrupy import SnapshotAssertion from homeassistant.core import HomeAssistant +from homeassistant.util import dt as dt_util -from tests.common import MockConfigEntry, load_fixture +from tests.common import MockConfigEntry from tests.components.diagnostics import get_diagnostics_for_config_entry from tests.typing import ClientSessionGenerator @@ -11,27 +13,14 @@ from tests.typing import ClientSessionGenerator async def test_diagnostics( hass: HomeAssistant, hass_client: ClientSessionGenerator, + mock_device: RokuDevice, init_integration: MockConfigEntry, + snapshot: SnapshotAssertion, ) -> None: """Test diagnostics for config entry.""" - diagnostics_data = json.loads(load_fixture("roku/roku3-diagnostics-data.json")) + mock_device.state.at = dt_util.parse_datetime("2023-08-15 17:00:00-00:00") - result = await get_diagnostics_for_config_entry(hass, hass_client, init_integration) - - assert isinstance(result, dict) - assert isinstance(result["entry"], dict) - assert result["entry"]["data"] == {"host": "192.168.1.160"} - assert result["entry"]["unique_id"] == "1GU48T017973" - - assert isinstance(result["data"], dict) - assert result["data"]["app"] == diagnostics_data["app"] - assert result["data"]["apps"] == diagnostics_data["apps"] - assert result["data"]["channel"] == diagnostics_data["channel"] - assert result["data"]["channels"] == diagnostics_data["channels"] - assert result["data"]["info"] == diagnostics_data["info"] - assert result["data"]["media"] == diagnostics_data["media"] - - data_state = result["data"]["state"] - assert isinstance(data_state, dict) - assert data_state["available"] == diagnostics_data["state"]["available"] - assert data_state["standby"] == diagnostics_data["state"]["standby"] + assert ( + await get_diagnostics_for_config_entry(hass, hass_client, init_integration) + == snapshot + )