@@ -1873,6 +1873,26 @@ async def test_check_saved_episodes(
18731873 )
18741874
18751875
1876+ async def test_check_saved_episode (
1877+ responses : aioresponses ,
1878+ authenticated_client : SpotifyClient ,
1879+ ) -> None :
1880+ """Test checking saved episode."""
1881+ responses .get (
1882+ f"{ SPOTIFY_URL } /v1/me/episodes/contains?ids=18yVqkdbdRvS24c0Ilj2ci" ,
1883+ status = 200 ,
1884+ body = load_fixture ("tracks_saved.json" ),
1885+ )
1886+ assert await authenticated_client .is_episode_saved ("18yVqkdbdRvS24c0Ilj2ci" ) is True
1887+ responses .assert_called_once_with (
1888+ f"{ SPOTIFY_URL } /v1/me/episodes/contains" ,
1889+ METH_GET ,
1890+ headers = HEADERS ,
1891+ params = {"ids" : "18yVqkdbdRvS24c0Ilj2ci" },
1892+ json = None ,
1893+ )
1894+
1895+
18761896async def test_check_no_saved_episodes (
18771897 responses : aioresponses ,
18781898 authenticated_client : SpotifyClient ,
@@ -2470,6 +2490,72 @@ async def test_check_saved_tracks(
24702490 )
24712491
24722492
2493+ async def test_check_saved_track (
2494+ responses : aioresponses ,
2495+ authenticated_client : SpotifyClient ,
2496+ ) -> None :
2497+ """Test checking saved track."""
2498+ responses .get (
2499+ f"{ SPOTIFY_URL } /v1/me/tracks/contains?ids=18yVqkdbdRvS24c0Ilj2ci" ,
2500+ status = 200 ,
2501+ body = load_fixture ("tracks_saved.json" ),
2502+ )
2503+ assert await authenticated_client .is_track_saved ("18yVqkdbdRvS24c0Ilj2ci" ) is True
2504+ responses .assert_called_once_with (
2505+ f"{ SPOTIFY_URL } /v1/me/tracks/contains" ,
2506+ METH_GET ,
2507+ headers = HEADERS ,
2508+ params = {"ids" : "18yVqkdbdRvS24c0Ilj2ci" },
2509+ json = None ,
2510+ )
2511+
2512+
2513+ @pytest .mark .parametrize (
2514+ ("prefix" , "url_part" ),
2515+ [
2516+ ("spotify:track:" , "tracks" ),
2517+ ("spotify:episode:" , "episodes" ),
2518+ ("spotify:show:" , "shows" ),
2519+ ("spotify:album:" , "albums" ),
2520+ ],
2521+ )
2522+ async def test_check_saved_item (
2523+ responses : aioresponses ,
2524+ authenticated_client : SpotifyClient ,
2525+ prefix : str ,
2526+ url_part : str ,
2527+ ) -> None :
2528+ """Test checking saved track."""
2529+ responses .get (
2530+ f"{ SPOTIFY_URL } /v1/me/{ url_part } /contains?ids=18yVqkdbdRvS24c0Ilj2ci" ,
2531+ status = 200 ,
2532+ body = load_fixture ("tracks_saved.json" ),
2533+ )
2534+ assert (
2535+ await authenticated_client .is_added_to_library (
2536+ f"{ prefix } 18yVqkdbdRvS24c0Ilj2ci"
2537+ )
2538+ is True
2539+ )
2540+ responses .assert_called_once_with (
2541+ f"{ SPOTIFY_URL } /v1/me/{ url_part } /contains" ,
2542+ METH_GET ,
2543+ headers = HEADERS ,
2544+ params = {"ids" : "18yVqkdbdRvS24c0Ilj2ci" },
2545+ json = None ,
2546+ )
2547+
2548+
2549+ async def test_checking_invalid_uri (
2550+ authenticated_client : SpotifyClient ,
2551+ ) -> None :
2552+ """Test checking saved track."""
2553+ with pytest .raises (ValueError , match = "Invalid URI format" ):
2554+ await authenticated_client .is_added_to_library (
2555+ "spotify:new:18yVqkdbdRvS24c0Ilj2ci"
2556+ )
2557+
2558+
24732559async def test_check_no_saved_tracks (
24742560 responses : aioresponses ,
24752561 authenticated_client : SpotifyClient ,
0 commit comments