@@ -2245,3 +2245,124 @@ async def test_get_audio_features(
22452245 params = None ,
22462246 json = None ,
22472247 )
2248+
2249+
2250+ async def test_save_shows (
2251+ responses : aioresponses ,
2252+ authenticated_client : SpotifyClient ,
2253+ ) -> None :
2254+ """Test saving shows."""
2255+ responses .put (
2256+ f"{ SPOTIFY_URL } /v1/me/shows?ids=0TnOYISbd1XYRBk9myaseg" ,
2257+ status = 200 ,
2258+ body = "" ,
2259+ )
2260+ await authenticated_client .save_shows (["0TnOYISbd1XYRBk9myaseg" ])
2261+ responses .assert_called_once_with (
2262+ f"{ SPOTIFY_URL } /v1/me/shows" ,
2263+ METH_PUT ,
2264+ headers = HEADERS ,
2265+ params = {"ids" : "0TnOYISbd1XYRBk9myaseg" },
2266+ json = None ,
2267+ )
2268+
2269+
2270+ async def test_save_no_shows (
2271+ responses : aioresponses ,
2272+ authenticated_client : SpotifyClient ,
2273+ ) -> None :
2274+ """Test saving no shows."""
2275+ await authenticated_client .save_shows ([])
2276+ responses .assert_not_called () # type: ignore[no-untyped-call]
2277+
2278+
2279+ async def test_save_too_many_shows (
2280+ responses : aioresponses ,
2281+ authenticated_client : SpotifyClient ,
2282+ ) -> None :
2283+ """Test saving too many shows."""
2284+ with pytest .raises (ValueError , match = "Maximum of 50 shows can be saved at once" ):
2285+ await authenticated_client .save_shows (["abc" ] * 51 )
2286+ responses .assert_not_called () # type: ignore[no-untyped-call]
2287+
2288+
2289+ async def test_remove_shows (
2290+ responses : aioresponses ,
2291+ authenticated_client : SpotifyClient ,
2292+ ) -> None :
2293+ """Test removing shows."""
2294+ responses .delete (
2295+ f"{ SPOTIFY_URL } /v1/me/shows?ids=0TnOYISbd1XYRBk9myaseg" ,
2296+ status = 200 ,
2297+ body = "" ,
2298+ )
2299+ await authenticated_client .remove_saved_shows (["0TnOYISbd1XYRBk9myaseg" ])
2300+ responses .assert_called_once_with (
2301+ f"{ SPOTIFY_URL } /v1/me/shows" ,
2302+ METH_DELETE ,
2303+ headers = HEADERS ,
2304+ params = {"ids" : "0TnOYISbd1XYRBk9myaseg" },
2305+ json = None ,
2306+ )
2307+
2308+
2309+ async def test_remove_no_shows (
2310+ responses : aioresponses ,
2311+ authenticated_client : SpotifyClient ,
2312+ ) -> None :
2313+ """Test removing no shows."""
2314+ await authenticated_client .remove_saved_shows ([])
2315+ responses .assert_not_called () # type: ignore[no-untyped-call]
2316+
2317+
2318+ async def test_remove_too_many_shows (
2319+ responses : aioresponses ,
2320+ authenticated_client : SpotifyClient ,
2321+ ) -> None :
2322+ """Test removing too many shows."""
2323+ with pytest .raises (ValueError , match = "Maximum of 50 shows can be removed at once" ):
2324+ await authenticated_client .remove_saved_shows (["abc" ] * 51 )
2325+ responses .assert_not_called () # type: ignore[no-untyped-call]
2326+
2327+
2328+ async def test_check_saved_shows (
2329+ responses : aioresponses ,
2330+ snapshot : SnapshotAssertion ,
2331+ authenticated_client : SpotifyClient ,
2332+ ) -> None :
2333+ """Test checking saved shows."""
2334+ responses .get (
2335+ f"{ SPOTIFY_URL } /v1/me/shows/contains?ids=18yVqkdbdRvS24c0Ilj2ci%2C1HGw3J3NxZO1TP1BTtVhpZ" ,
2336+ status = 200 ,
2337+ body = load_fixture ("shows_saved.json" ),
2338+ )
2339+ response = await authenticated_client .are_shows_saved (
2340+ ["18yVqkdbdRvS24c0Ilj2ci" , "1HGw3J3NxZO1TP1BTtVhpZ" ]
2341+ )
2342+ assert response == snapshot
2343+ responses .assert_called_once_with (
2344+ f"{ SPOTIFY_URL } /v1/me/shows/contains" ,
2345+ METH_GET ,
2346+ headers = HEADERS ,
2347+ params = {"ids" : "18yVqkdbdRvS24c0Ilj2ci,1HGw3J3NxZO1TP1BTtVhpZ" },
2348+ json = None ,
2349+ )
2350+
2351+
2352+ async def test_check_no_saved_shows (
2353+ responses : aioresponses ,
2354+ authenticated_client : SpotifyClient ,
2355+ ) -> None :
2356+ """Test checking no saved shows."""
2357+ assert await authenticated_client .are_shows_saved ([]) == {}
2358+ responses .assert_not_called () # type: ignore[no-untyped-call]
2359+
2360+
2361+ async def test_check_too_many_saved_shows (
2362+ responses : aioresponses ,
2363+ authenticated_client : SpotifyClient ,
2364+ ) -> None :
2365+ """Test checking too many saved shows."""
2366+ with pytest .raises (ValueError , match = "Maximum of 50 shows can be checked at once" ):
2367+ await authenticated_client .are_shows_saved (["abc" ] * 51 )
2368+ responses .assert_not_called () # type: ignore[no-untyped-call]
0 commit comments