From fe130b62c8453dd6cdb409a31fda1fd460e2a97c Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Mon, 7 Oct 2024 18:00:54 +0200 Subject: [PATCH] Replace Spotify fixtures (#127850) Replace fixtures with real life ones --- tests/components/spotify/conftest.py | 4 +- .../spotify/fixtures/current_user.json | 33 ++++++- .../fixtures/current_user_playlist.json | 96 ++++++++++++++++--- .../spotify/snapshots/test_media_browser.ambr | 32 +++++-- tests/components/spotify/test_config_flow.py | 2 +- 5 files changed, 145 insertions(+), 22 deletions(-) diff --git a/tests/components/spotify/conftest.py b/tests/components/spotify/conftest.py index 58100ee676f..0adeb63c8a5 100644 --- a/tests/components/spotify/conftest.py +++ b/tests/components/spotify/conftest.py @@ -31,7 +31,7 @@ def mock_config_entry(expires_at: int) -> MockConfigEntry: return MockConfigEntry( domain=DOMAIN, title="spotify_1", - unique_id="fake_id", + unique_id="1112264111", data={ "auth_implementation": DOMAIN, "token": { @@ -40,7 +40,7 @@ def mock_config_entry(expires_at: int) -> MockConfigEntry: "expires_at": expires_at, "scope": SCOPES, }, - "id": "fake_id", + "id": "1112264111", "name": "spotify_account_1", }, entry_id="01J5TX5A0FF6G5V0QJX6HBC94T", diff --git a/tests/components/spotify/fixtures/current_user.json b/tests/components/spotify/fixtures/current_user.json index 4684af40f58..a4f95b6c33e 100644 --- a/tests/components/spotify/fixtures/current_user.json +++ b/tests/components/spotify/fixtures/current_user.json @@ -1,4 +1,33 @@ { - "id": "fake_id", - "display_name": "frenck" + "display_name": "Henk", + "external_urls": { + "spotify": "https://open.spotify.com/user/1112264111" + }, + "href": "https://api.spotify.com/v1/users/1112264111", + "id": "1112264111", + "images": [ + { + "url": "https://i.scdn.co/image/ab67757000003b8246569a64d252247acb1491bc", + "height": 64, + "width": 64 + }, + { + "url": "https://i.scdn.co/image/ab6775700000ee8546569a64d252247acb1491bc", + "height": 300, + "width": 300 + } + ], + "type": "user", + "uri": "spotify:user:1112264111", + "followers": { + "href": null, + "total": 21 + }, + "country": "NL", + "product": "premium", + "explicit_content": { + "filter_enabled": false, + "filter_locked": false + }, + "email": "henk@outlook.com" } diff --git a/tests/components/spotify/fixtures/current_user_playlist.json b/tests/components/spotify/fixtures/current_user_playlist.json index e9f01cbbc31..c9d306504db 100644 --- a/tests/components/spotify/fixtures/current_user_playlist.json +++ b/tests/components/spotify/fixtures/current_user_playlist.json @@ -1,18 +1,92 @@ { - "href": "https://api.spotify.com/v1/users/31oesphrnacjcf7vw5bf6odx3oiu/playlists?offset=0&limit=48", - "limit": 48, - "next": null, - "offset": 0, - "previous": null, - "total": 1, + "href": "https://api.spotify.com/v1/users/1112264111/playlists?offset=0&limit=20", "items": [ { - "collaborative": null, + "collaborative": false, "description": "", - "id": "unique_identifier_00", - "name": "Playlist1", + "external_urls": { + "spotify": "https://open.spotify.com/playlist/4WkWJ0EjHEFASDevhM8oPw" + }, + "href": "https://api.spotify.com/v1/playlists/4WkWJ0EjHEFASDevhM8oPw", + "id": "4WkWJ0EjHEFASDevhM8oPw", + "images": [ + { + "height": 640, + "url": "https://i.scdn.co/image/ab67616d0000b273d061f5bfae8d38558f3698c1", + "width": 640 + } + ], + "name": "Hyper", + "owner": { + "display_name": "Henk", + "external_urls": { + "spotify": "https://open.spotify.com/user/1112264111" + }, + "href": "https://api.spotify.com/v1/users/1112264111", + "id": "1112264111", + "type": "user", + "uri": "spotify:user:1112264111" + }, + "primary_color": null, + "public": true, + "snapshot_id": "Myw2ZjkyN2Q1ZWEwMjU1YWJjM2EwOWQ5YzA2ZDJjYjIzNTEzNzVmYmVl", + "tracks": { + "href": "https://api.spotify.com/v1/playlists/4WkWJ0EjHEFASDevhM8oPw/tracks", + "total": 1 + }, "type": "playlist", - "uri": "spotify:playlist:unique_identifier_00" + "uri": "spotify:playlist:4WkWJ0EjHEFASDevhM8oPw" + }, + { + "collaborative": false, + "description": "", + "external_urls": { + "spotify": "https://open.spotify.com/playlist/1RHirWgH1weMsBLi4KOK9d" + }, + "href": "https://api.spotify.com/v1/playlists/1RHirWgH1weMsBLi4KOK9d", + "id": "1RHirWgH1weMsBLi4KOK9d", + "images": [ + { + "height": 640, + "url": "https://mosaic.scdn.co/640/ab67616d0000b2732f3e58dd611d177973cb3a8cab67616d0000b27345cab965cb4639a4e669564aab67616d0000b2739e83c93811be6abfad8649d6ab67616d0000b273e4c03429788f0aff263a5fc6", + "width": 640 + }, + { + "height": 300, + "url": "https://mosaic.scdn.co/300/ab67616d0000b2732f3e58dd611d177973cb3a8cab67616d0000b27345cab965cb4639a4e669564aab67616d0000b2739e83c93811be6abfad8649d6ab67616d0000b273e4c03429788f0aff263a5fc6", + "width": 300 + }, + { + "height": 60, + "url": "https://mosaic.scdn.co/60/ab67616d0000b2732f3e58dd611d177973cb3a8cab67616d0000b27345cab965cb4639a4e669564aab67616d0000b2739e83c93811be6abfad8649d6ab67616d0000b273e4c03429788f0aff263a5fc6", + "width": 60 + } + ], + "name": "Ain’t got shit on me", + "owner": { + "display_name": "Rens Boeser", + "external_urls": { + "spotify": "https://open.spotify.com/user/317g2sbpe3ccycu45fes6lfr5lpe" + }, + "href": "https://api.spotify.com/v1/users/317g2sbpe3ccycu45fes6lfr5lpe", + "id": "317g2sbpe3ccycu45fes6lfr5lpe", + "type": "user", + "uri": "spotify:user:317g2sbpe3ccycu45fes6lfr5lpe" + }, + "primary_color": null, + "public": false, + "snapshot_id": "MjksMTdlMGU4ZGIxZWY5NWRkNjVkMzQ1YzUxYjk3YWZkMDdhNzRjNWE0Zg==", + "tracks": { + "href": "https://api.spotify.com/v1/playlists/1RHirWgH1weMsBLi4KOK9d/tracks", + "total": 28 + }, + "type": "playlist", + "uri": "spotify:playlist:1RHirWgH1weMsBLi4KOK9d" } - ] + ], + "limit": 18, + "next": "https://api.spotify.com/v1/users/1112264111/playlists?offset=18&limit=20", + "offset": 0, + "previous": null, + "total": 101 } diff --git a/tests/components/spotify/snapshots/test_media_browser.ambr b/tests/components/spotify/snapshots/test_media_browser.ambr index 7457d31e2ca..4c397087805 100644 --- a/tests/components/spotify/snapshots/test_media_browser.ambr +++ b/tests/components/spotify/snapshots/test_media_browser.ambr @@ -134,10 +134,20 @@ 'can_play': True, 'children_media_class': , 'media_class': , - 'media_content_id': 'spotify://01j5tx5a0ff6g5v0qjx6hbc94t/spotify:playlist:unique_identifier_00', + 'media_content_id': 'spotify://01j5tx5a0ff6g5v0qjx6hbc94t/spotify:playlist:4WkWJ0EjHEFASDevhM8oPw', 'media_content_type': 'spotify://playlist', - 'thumbnail': None, - 'title': 'Playlist1', + 'thumbnail': 'https://i.scdn.co/image/ab67616d0000b273d061f5bfae8d38558f3698c1', + 'title': 'Hyper', + }), + dict({ + 'can_expand': True, + 'can_play': True, + 'children_media_class': , + 'media_class': , + 'media_content_id': 'spotify://01j5tx5a0ff6g5v0qjx6hbc94t/spotify:playlist:1RHirWgH1weMsBLi4KOK9d', + 'media_content_type': 'spotify://playlist', + 'thumbnail': 'https://mosaic.scdn.co/640/ab67616d0000b2732f3e58dd611d177973cb3a8cab67616d0000b27345cab965cb4639a4e669564aab67616d0000b2739e83c93811be6abfad8649d6ab67616d0000b273e4c03429788f0aff263a5fc6', + 'title': 'Ain’t got shit on me', }), ]), 'children_media_class': , @@ -159,10 +169,20 @@ 'can_play': True, 'children_media_class': , 'media_class': , - 'media_content_id': 'spotify://32oesphrnacjcf7vw5bf6odx3/spotify:playlist:unique_identifier_00', + 'media_content_id': 'spotify://32oesphrnacjcf7vw5bf6odx3/spotify:playlist:4WkWJ0EjHEFASDevhM8oPw', 'media_content_type': 'spotify://playlist', - 'thumbnail': None, - 'title': 'Playlist1', + 'thumbnail': 'https://i.scdn.co/image/ab67616d0000b273d061f5bfae8d38558f3698c1', + 'title': 'Hyper', + }), + dict({ + 'can_expand': True, + 'can_play': True, + 'children_media_class': , + 'media_class': , + 'media_content_id': 'spotify://32oesphrnacjcf7vw5bf6odx3/spotify:playlist:1RHirWgH1weMsBLi4KOK9d', + 'media_content_type': 'spotify://playlist', + 'thumbnail': 'https://mosaic.scdn.co/640/ab67616d0000b2732f3e58dd611d177973cb3a8cab67616d0000b27345cab965cb4639a4e669564aab67616d0000b2739e83c93811be6abfad8649d6ab67616d0000b273e4c03429788f0aff263a5fc6', + 'title': 'Ain’t got shit on me', }), ]), 'children_media_class': , diff --git a/tests/components/spotify/test_config_flow.py b/tests/components/spotify/test_config_flow.py index 68b1f0583d6..f4719c0147c 100644 --- a/tests/components/spotify/test_config_flow.py +++ b/tests/components/spotify/test_config_flow.py @@ -115,7 +115,7 @@ async def test_full_flow( assert result["type"] is FlowResultType.CREATE_ENTRY result["data"]["token"].pop("expires_at") - assert result["data"]["name"] == "frenck" + assert result["data"]["name"] == "Henk" assert result["data"]["token"] == { "refresh_token": "mock-refresh-token", "access_token": "mock-access-token",