@@ -168,6 +168,52 @@ async def test_get_album_tracks(
168168 )
169169
170170
171+ async def test_save_albums (
172+ responses : aioresponses ,
173+ authenticated_client : SpotifyClient ,
174+ ) -> None :
175+ """Test saving albums."""
176+ responses .put (
177+ f"{ SPOTIFY_URL } /v1/me/albums?ids=3IqzqH6ShrRtie9Yd2ODyG%252C1A2GTWGtFfWp7KSQTwWOyo%252C2noRn2Aes5aoNVsU6iWTh" ,
178+ status = 200 ,
179+ )
180+ await authenticated_client .save_albums (
181+ [
182+ "spotify:album:3IqzqH6ShrRtie9Yd2ODyG" ,
183+ "1A2GTWGtFfWp7KSQTwWOyo" ,
184+ "2noRn2Aes5aoNVsU6iWTh" ,
185+ ]
186+ )
187+ responses .assert_called_once_with (
188+ f"{ SPOTIFY_URL } /v1/me/albums" ,
189+ METH_PUT ,
190+ headers = HEADERS ,
191+ params = {
192+ "ids" : "3IqzqH6ShrRtie9Yd2ODyG,1A2GTWGtFfWp7KSQTwWOyo,2noRn2Aes5aoNVsU6iWTh"
193+ },
194+ json = None ,
195+ )
196+
197+
198+ async def test_save_no_albums (
199+ responses : aioresponses ,
200+ authenticated_client : SpotifyClient ,
201+ ) -> None :
202+ """Test saving no albums."""
203+ await authenticated_client .save_albums ([])
204+ responses .assert_not_called () # type: ignore[no-untyped-call]
205+
206+
207+ async def test_save_too_many_albums (
208+ responses : aioresponses ,
209+ authenticated_client : SpotifyClient ,
210+ ) -> None :
211+ """Test saving too many albums."""
212+ with pytest .raises (ValueError , match = "Maximum of 50 albums can be saved at once" ):
213+ await authenticated_client .save_albums (["abc" ] * 51 )
214+ responses .assert_not_called () # type: ignore[no-untyped-call]
215+
216+
171217@pytest .mark .parametrize (
172218 "playback_fixture" ,
173219 [
0 commit comments