diff --git a/tests/components/netatmo/test_media_source.py b/tests/components/netatmo/test_media_source.py
index 1773c0d83da..fd36c57dfd1 100644
--- a/tests/components/netatmo/test_media_source.py
+++ b/tests/components/netatmo/test_media_source.py
@@ -1,4 +1,6 @@
"""Test Local Media Source."""
+import ast
+
import pytest
from homeassistant.components import media_source
@@ -7,6 +9,8 @@ from homeassistant.components.media_source.models import PlayMedia
from homeassistant.components.netatmo import DATA_CAMERAS, DATA_EVENTS, DOMAIN
from homeassistant.setup import async_setup_component
+from tests.common import load_fixture
+
async def test_async_browse_media(hass):
"""Test browse media."""
@@ -14,67 +18,9 @@ async def test_async_browse_media(hass):
# Prepare cached Netatmo event date
hass.data[DOMAIN] = {}
- hass.data[DOMAIN][DATA_EVENTS] = {
- "12:34:56:78:90:ab": {
- 1599152672: {
- "id": "12345",
- "type": "person",
- "time": 1599152672,
- "camera_id": "12:34:56:78:90:ab",
- "snapshot": {
- "url": "https://netatmocameraimage",
- },
- "video_id": "98765",
- "video_status": "available",
- "message": "Paulus seen",
- "media_url": "http:///files/high/index.m3u8",
- },
- 1599152673: {
- "id": "12346",
- "type": "person",
- "time": 1599152673,
- "camera_id": "12:34:56:78:90:ab",
- "snapshot": {
- "url": "https://netatmocameraimage",
- },
- "message": "Tobias seen",
- },
- 1599152674: {
- "id": "12347",
- "type": "outdoor",
- "time": 1599152674,
- "camera_id": "12:34:56:78:90:ac",
- "snapshot": {
- "url": "https://netatmocameraimage",
- },
- "video_id": "98766",
- "video_status": "available",
- "event_list": [
- {
- "type": "vehicle",
- "time": 1599152674,
- "id": "12347-0",
- "offset": 0,
- "message": "Vehicle detected",
- "snapshot": {
- "url": "https://netatmocameraimage",
- },
- },
- {
- "type": "human",
- "time": 1599152674,
- "id": "12347-1",
- "offset": 8,
- "message": "Person detected",
- "snapshot": {
- "url": "https://netatmocameraimage",
- },
- },
- ],
- "media_url": "http:///files/high/index.m3u8",
- },
- }
- }
+ hass.data[DOMAIN][DATA_EVENTS] = ast.literal_eval(
+ load_fixture("netatmo/events.txt")
+ )
hass.data[DOMAIN][DATA_CAMERAS] = {
"12:34:56:78:90:ab": "MyCamera",
diff --git a/tests/fixtures/netatmo/events.txt b/tests/fixtures/netatmo/events.txt
new file mode 100644
index 00000000000..f2bc29f782c
--- /dev/null
+++ b/tests/fixtures/netatmo/events.txt
@@ -0,0 +1,61 @@
+{
+ "12:34:56:78:90:ab": {
+ 1599152672: {
+ "id": "12345",
+ "type": "person",
+ "time": 1599152672,
+ "camera_id": "12:34:56:78:90:ab",
+ "snapshot": {
+ "url": "https://netatmocameraimage",
+ },
+ "video_id": "98765",
+ "video_status": "available",
+ "message": "Paulus seen",
+ "media_url": "http:///files/high/index.m3u8",
+ },
+ 1599152673: {
+ "id": "12346",
+ "type": "person",
+ "time": 1599152673,
+ "camera_id": "12:34:56:78:90:ab",
+ "snapshot": {
+ "url": "https://netatmocameraimage",
+ },
+ "message": "Tobias seen",
+ },
+ 1599152674: {
+ "id": "12347",
+ "type": "outdoor",
+ "time": 1599152674,
+ "camera_id": "12:34:56:78:90:ac",
+ "snapshot": {
+ "url": "https://netatmocameraimage",
+ },
+ "video_id": "98766",
+ "video_status": "available",
+ "event_list": [
+ {
+ "type": "vehicle",
+ "time": 1599152674,
+ "id": "12347-0",
+ "offset": 0,
+ "message": "Vehicle detected",
+ "snapshot": {
+ "url": "https://netatmocameraimage",
+ },
+ },
+ {
+ "type": "human",
+ "time": 1599152674,
+ "id": "12347-1",
+ "offset": 8,
+ "message": "Person detected",
+ "snapshot": {
+ "url": "https://netatmocameraimage",
+ },
+ },
+ ],
+ "media_url": "http:///files/high/index.m3u8",
+ },
+ }
+}
\ No newline at end of file