import pytest @pytest.fixture def spotify_track_response(): def response(track_id: str = "", name: str = "DHL", add_markets: bool = False): res = { "album": { "album_type": "single", "artists": [ { "external_urls": {"spotify": "https://open.spotify.com/artist/2h93pZq0e7k5yf4dywlkpM"}, "href": "https://api.spotify.com/v1/artists/2h93pZq0e7k5yf4dywlkpM", "id": "2h93pZq0e7k5yf4dywlkpM", "name": "Frank Ocean", "type": "artist", "uri": "spotify:artist:2h93pZq0e7k5yf4dywlkpM", } ], "external_urls": {"spotify": "https://open.spotify.com/album/1Fh1gzTOImG12M35w3nqQF"}, "href": "https://api.spotify.com/v1/albums/1Fh1gzTOImG12M35w3nqQF", "id": "1Fh1gzTOImG12M35w3nqQF", "images": [ { "height": 640, "url": "https://i.scdn.co/image/939ddeb375832f60092baad928d2b6b057bd8320", "width": 640, }, { "height": 300, "url": "https://i.scdn.co/image/76f75fcfba06f21c66b02441cf8586cf4547a522", "width": 300, }, { "height": 64, "url": "https://i.scdn.co/image/71be557062386e97b0b257876ed55ccb662c9d77", "width": 64, }, ], "name": name, "release_date": "2019-10-19", "release_date_precision": "day", "total_tracks": 1, "type": "album", "uri": "spotify:album:1Fh1gzTOImG12M35w3nqQF", }, "artists": [ { "external_urls": {"spotify": "https://open.spotify.com/artist/2h93pZq0e7k5yf4dywlkpM"}, "href": "https://api.spotify.com/v1/artists/2h93pZq0e7k5yf4dywlkpM", "id": "2h93pZq0e7k5yf4dywlkpM", "name": "Frank Ocean", "type": "artist", "uri": "spotify:artist:2h93pZq0e7k5yf4dywlkpM", }, { "external_urls": {"spotify": "https://open.spotify.com/artist/2h93pZq0e7k5yf4dywlksS"}, "href": "https://api.spotify.com/v1/artists/2h93pZq0e7k5yf4dywlksS", "id": "2h93pZq0e7k5yf4dywlksS", "name": "Test test", "type": "artist", "uri": "spotify:artist:2h93pZq0e7k5yf4dywlksS", }, ], "disc_number": 1, "duration_ms": 268893, "explicit": True, "external_ids": {"isrc": "QM24S1926144"}, "external_urls": {"spotify": f"https://open.spotify.com/track/{track_id}"}, "href": f"https://api.spotify.com/v1/tracks/{track_id}", "id": track_id, "is_local": False, "is_playable": True, "name": name, "popularity": 82, "preview_url": "https://p.scdn.co/mp3-preview/f775f9feca8da04049751874010c4ddead14dd41?cid=" "c3a2bff1dba240e99af7826567abf96c", "track_number": 1, "type": "track", "uri": f"spotify:track:{track_id}", } if add_markets: markets = [ "AD", "AE", "AG", "AL", "AM", "AO", "AR", "AT", "AU", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BN", "BO", "BR", "BS", "BT", "BW", "BY", "BZ", "CA", "CH", "CI", "CL", "CM", "CO", "CR", "CV", "CW", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "ES", "FI", "FJ", "FM", "FR", "GA", "GB", "GD", "GE", "GH", "GM", "GN", "GQ", "GR", "GT", "GW", "GY", "HK", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KR", "KW", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "MA", "MC", "MD", "ME", "MG", "MH", "MK", "ML", "MN", "MO", "MR", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NE", "NG", "NI", "NL", "NO", "NP", "NR", "NZ", "OM", "PA", "PE", "PG", "PH", "PK", "PL", "PS", "PT", "PW", "PY", "QA", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SE", "SG", "SI", "SK", "SL", "SM", "SN", "SR", "ST", "SV", "SZ", "TD", "TG", "TH", "TL", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "US", "UY", "UZ", "VC", "VN", "VU", "WS", "XK", "ZA", "ZM", "ZW", ] res["album"]["available_markets"] = markets res["available_markets"] = markets return res return response @pytest.fixture def spotify_track_image_response(spotify_track_response): def response(track_id=""): return {"id": track_id, "image_url": "https://i.scdn.co/image/76f75fcfba06f21c66b02441cf8586cf4547a522"} return response @pytest.fixture def spotify_playlist_tracklist(): def response(playlist_id: str): return { "collaborative": False, "description": "All the hits you'll need to make your summer sizzle.", "external_urls": {"spotify": f"https://open.spotify.com/playlist/{playlist_id}"}, "followers": {"href": "None", "total": 972640}, "href": f"https://api.spotify.com/v1/playlists/{playlist_id}", "id": playlist_id, "images": [ { "height": "None", "url": "https://i.scdn.co/image/ab67706f000000033a650c8688970d43470a0094", "width": "None", } ], "name": "Summer Hits", "owner": { "display_name": "Spotify", "external_urls": {"spotify": "https://open.spotify.com/user/spotify"}, "href": "https://api.spotify.com/v1/users/spotify", "id": "spotify", "type": "user", "uri": "spotify:user:spotify", }, "primary_color": "#FFFFFF", "public": False, "snapshot_id": "MTYxMjM2NzczNiwwMDAwMDBjYTAwMDAwMTc3Njg5YjJlODMwMDAwMDE3Mjc2YTFiMDRm", "tracks": { "items": [ { "added_at": "2020-10-02T12:47:36Z", "added_by": { "external_urls": {"spotify": "https://open.spotify.com/user/"}, "href": "https://api.spotify.com/v1/users/", "id": "", "type": "user", "uri": "spotify:user:", }, "is_local": False, "primary_color": "#b69471", "track": { "album": { "album_type": "single", "artists": [ { "external_urls": { "spotify": "https://open.spotify.com/artist/1lmU3giNF3CSbkVSQmLpHQ" }, "href": "https://api.spotify.com/v1/artists/1lmU3giNF3CSbkVSQmLpHQ", "id": "1lmU3giNF3CSbkVSQmLpHQ", "name": "Surf Mesa", "type": "artist", "uri": "spotify:artist:1lmU3giNF3CSbkVSQmLpHQ", } ], "external_urls": {"spotify": "https://open.spotify.com/album/4MHHajvRTUHItDsvfdIC8B"}, "href": "https://api.spotify.com/v1/albums/4MHHajvRTUHItDsvfdIC8B", "id": "4MHHajvRTUHItDsvfdIC8B", "images": [ { "height": 640, "url": "https://i.scdn.co/image/ab67616d0000b273b3de5764cc02f94714487c86", "width": 640, }, { "height": 300, "url": "https://i.scdn.co/image/ab67616d00001e02b3de5764cc02f94714487c86", "width": 300, }, { "height": 64, "url": "https://i.scdn.co/image/ab67616d00004851b3de5764cc02f94714487c86", "width": 64, }, ], "name": "ily (i love you baby) (feat. Emilee)", "release_date": "2019-11-26", "release_date_precision": "day", "total_tracks": 1, "type": "album", "uri": "spotify:album:4MHHajvRTUHItDsvfdIC8B", }, "artists": [ { "external_urls": { "spotify": "https://open.spotify.com/artist/1lmU3giNF3CSbkVSQmLpHQ" }, "href": "https://api.spotify.com/v1/artists/1lmU3giNF3CSbkVSQmLpHQ", "id": "1lmU3giNF3CSbkVSQmLpHQ", "name": "Surf Mesa", "type": "artist", "uri": "spotify:artist:1lmU3giNF3CSbkVSQmLpHQ", }, { "external_urls": { "spotify": "https://open.spotify.com/artist/4ArPQ1Opcksbbf3CPwEjWE" }, "href": "https://api.spotify.com/v1/artists/4ArPQ1Opcksbbf3CPwEjWE", "id": "4ArPQ1Opcksbbf3CPwEjWE", "name": "Emilee", "type": "artist", "uri": "spotify:artist:4ArPQ1Opcksbbf3CPwEjWE", }, ], "disc_number": 1, "duration_ms": 176546, "episode": False, "explicit": False, "external_ids": {"isrc": "QZJRC1945204"}, "external_urls": {"spotify": "https://open.spotify.com/track/62aP9fBQKYKxi7PDXwcUAS"}, "href": "https://api.spotify.com/v1/tracks/62aP9fBQKYKxi7PDXwcUAS", "id": "62aP9fBQKYKxi7PDXwcUAS", "is_local": False, "name": "ily (i love you baby) (feat. Emilee)", "popularity": 84, "preview_url": "None", "track": False, "track_number": 1, "type": "track", "uri": "spotify:track:62aP9fBQKYKxi7PDXwcUAS", }, "video_thumbnail": {"url": "None"}, }, { "added_at": "2020-10-02T12:47:36Z", "added_by": { "external_urls": {"spotify": "https://open.spotify.com/user/"}, "href": "https://api.spotify.com/v1/users/", "id": "", "type": "user", "uri": "spotify:user:", }, "is_local": False, "primary_color": "#eb868e", "track": { "album": { "album_type": "single", "artists": [ { "external_urls": { "spotify": "https://open.spotify.com/artist/0H39MdGGX6dbnnQPt6NQkZ" }, "href": "https://api.spotify.com/v1/artists/0H39MdGGX6dbnnQPt6NQkZ", "id": "0H39MdGGX6dbnnQPt6NQkZ", "name": "SAINt JHN", "type": "artist", "uri": "spotify:artist:0H39MdGGX6dbnnQPt6NQkZ", }, { "external_urls": { "spotify": "https://open.spotify.com/artist/5rGrDvrLOV2VV8SCFVGWlj" }, "href": "https://api.spotify.com/v1/artists/5rGrDvrLOV2VV8SCFVGWlj", "id": "5rGrDvrLOV2VV8SCFVGWlj", "name": "Imanbek", "type": "artist", "uri": "spotify:artist:5rGrDvrLOV2VV8SCFVGWlj", }, ], "external_urls": {"spotify": "https://open.spotify.com/album/3GqSdhWjmMypMwPLtzoFYs"}, "href": "https://api.spotify.com/v1/albums/3GqSdhWjmMypMwPLtzoFYs", "id": "3GqSdhWjmMypMwPLtzoFYs", "images": [ { "height": 640, "url": "https://i.scdn.co/image/ab67616d0000b273b340b496cb7c38d727ff40be", "width": 640, }, { "height": 300, "url": "https://i.scdn.co/image/ab67616d00001e02b340b496cb7c38d727ff40be", "width": 300, }, { "height": 64, "url": "https://i.scdn.co/image/ab67616d00004851b340b496cb7c38d727ff40be", "width": 64, }, ], "name": "Roses (Imanbek Remix)", "release_date": "2019-10-09", "release_date_precision": "day", "total_tracks": 1, "type": "album", "uri": "spotify:album:3GqSdhWjmMypMwPLtzoFYs", }, "artists": [ { "external_urls": { "spotify": "https://open.spotify.com/artist/0H39MdGGX6dbnnQPt6NQkZ" }, "href": "https://api.spotify.com/v1/artists/0H39MdGGX6dbnnQPt6NQkZ", "id": "0H39MdGGX6dbnnQPt6NQkZ", "name": "SAINt JHN", "type": "artist", "uri": "spotify:artist:0H39MdGGX6dbnnQPt6NQkZ", }, { "external_urls": { "spotify": "https://open.spotify.com/artist/5rGrDvrLOV2VV8SCFVGWlj" }, "href": "https://api.spotify.com/v1/artists/5rGrDvrLOV2VV8SCFVGWlj", "id": "5rGrDvrLOV2VV8SCFVGWlj", "name": "Imanbek", "type": "artist", "uri": "spotify:artist:5rGrDvrLOV2VV8SCFVGWlj", }, ], "disc_number": 1, "duration_ms": 176840, "episode": False, "explicit": True, "external_ids": {"isrc": "RUB421901499"}, "external_urls": {"spotify": "https://open.spotify.com/track/24Yi9hE78yPEbZ4kxyoXAI"}, "href": "https://api.spotify.com/v1/tracks/24Yi9hE78yPEbZ4kxyoXAI", "id": "24Yi9hE78yPEbZ4kxyoXAI", "is_local": False, "name": "Roses - Imanbek Remix", "popularity": 87, "preview_url": "https://p.scdn.co/mp3-preview/9", "track": True, "track_number": 1, "type": "track", "uri": "spotify:track:24Yi9hE78yPEbZ4kxyoXAI", }, "video_thumbnail": {"url": "None"}, }, { "added_at": "2020-10-02T12:47:36Z", "added_by": { "external_urls": {"spotify": "https://open.spotify.com/user/"}, "href": "https://api.spotify.com/v1/users/", "id": "", "type": "user", "uri": "spotify:user:", }, "is_local": False, "primary_color": "#f3d86c", "track": { "album": { "album_type": "album", "artists": [ { "external_urls": { "spotify": "https://open.spotify.com/artist/4ETSs924pXMzjIeD6E9b4u" }, "href": "https://api.spotify.com/v1/artists/4ETSs924pXMzjIeD6E9b4u", "id": "4ETSs924pXMzjIeD6E9b4u", "name": "Surfaces", "type": "artist", "uri": "spotify:artist:4ETSs924pXMzjIeD6E9b4u", } ], "external_urls": {"spotify": "https://open.spotify.com/album/3mMWlBGocBwsS1Q0o9wvlc"}, "href": "https://api.spotify.com/v1/albums/3mMWlBGocBwsS1Q0o9wvlc", "id": "3mMWlBGocBwsS1Q0o9wvlc", "images": [ { "height": 640, "url": "https://i.scdn.co/image/ab67616d0000b2733667dc27da7b24360d6050d0", "width": 640, }, { "height": 300, "url": "https://i.scdn.co/image/ab67616d00001e023667dc27da7b24360d6050d0", "width": 300, }, { "height": 64, "url": "https://i.scdn.co/image/ab67616d000048513667dc27da7b24360d6050d0", "width": 64, }, ], "name": "Where the Light Is", "release_date": "2019-01-06", "release_date_precision": "day", "total_tracks": 10, "type": "album", "uri": "spotify:album:3mMWlBGocBwsS1Q0o9wvlc", }, "artists": [ { "external_urls": { "spotify": "https://open.spotify.com/artist/4ETSs924pXMzjIeD6E9b4u" }, "href": "https://api.spotify.com/v1/artists/4ETSs924pXMzjIeD6E9b4u", "id": "4ETSs924pXMzjIeD6E9b4u", "name": "Surfaces", "type": "artist", "uri": "spotify:artist:4ETSs924pXMzjIeD6E9b4u", } ], "disc_number": 1, "duration_ms": 158571, "episode": False, "explicit": False, "external_ids": {"isrc": "TCAEA1802695"}, "external_urls": {"spotify": "https://open.spotify.com/track/1Cv1YLb4q0RzL6pybtaMLo"}, "href": "https://api.spotify.com/v1/tracks/1Cv1YLb4q0RzL6pybtaMLo", "id": "1Cv1YLb4q0RzL6pybtaMLo", "is_local": False, "name": "Sunday Best", "popularity": 83, "preview_url": "None", "track": True, "track_number": 7, "type": "track", "uri": "spotify:track:1Cv1YLb4q0RzL6pybtaMLo", }, "video_thumbnail": {"url": "None"}, }, ], "total": 3, }, "type": "playlist", "uri": f"spotify:playlist:{playlist_id}", } return response