Skip to content

Commit

Permalink
Replace Spotify fixtures (home-assistant#127850)
Browse files Browse the repository at this point in the history
Replace fixtures with real life ones
  • Loading branch information
joostlek authored Oct 7, 2024
1 parent f0363ac commit fe130b6
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 22 deletions.
4 changes: 2 additions & 2 deletions tests/components/spotify/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand Down
33 changes: 31 additions & 2 deletions tests/components/spotify/fixtures/current_user.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
}
96 changes: 85 additions & 11 deletions tests/components/spotify/fixtures/current_user_playlist.json
Original file line number Diff line number Diff line change
@@ -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
}
32 changes: 26 additions & 6 deletions tests/components/spotify/snapshots/test_media_browser.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,20 @@
'can_play': True,
'children_media_class': <MediaClass.TRACK: 'track'>,
'media_class': <MediaClass.PLAYLIST: 'playlist'>,
'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': <MediaClass.TRACK: 'track'>,
'media_class': <MediaClass.PLAYLIST: 'playlist'>,
'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': <MediaClass.PLAYLIST: 'playlist'>,
Expand All @@ -159,10 +169,20 @@
'can_play': True,
'children_media_class': <MediaClass.TRACK: 'track'>,
'media_class': <MediaClass.PLAYLIST: 'playlist'>,
'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': <MediaClass.TRACK: 'track'>,
'media_class': <MediaClass.PLAYLIST: 'playlist'>,
'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': <MediaClass.PLAYLIST: 'playlist'>,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/spotify/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit fe130b6

Please sign in to comment.