|
6 | 6 | from typing import TYPE_CHECKING, Any |
7 | 7 |
|
8 | 8 | import aiohttp |
9 | | -from aiohttp.hdrs import METH_GET, METH_POST, METH_PUT |
| 9 | +from aiohttp.hdrs import METH_DELETE, METH_GET, METH_POST, METH_PUT |
10 | 10 | from aioresponses import CallbackResult, aioresponses |
11 | 11 | import pytest |
12 | 12 | from yarl import URL |
@@ -214,6 +214,52 @@ async def test_save_too_many_albums( |
214 | 214 | responses.assert_not_called() # type: ignore[no-untyped-call] |
215 | 215 |
|
216 | 216 |
|
| 217 | +async def test_removing_saved_albums( |
| 218 | + responses: aioresponses, |
| 219 | + authenticated_client: SpotifyClient, |
| 220 | +) -> None: |
| 221 | + """Test deleting saved albums.""" |
| 222 | + responses.delete( |
| 223 | + f"{SPOTIFY_URL}/v1/me/albums?ids=3IqzqH6ShrRtie9Yd2ODyG%252C1A2GTWGtFfWp7KSQTwWOyo%252C2noRn2Aes5aoNVsU6iWTh", |
| 224 | + status=200, |
| 225 | + ) |
| 226 | + await authenticated_client.remove_saved_albums( |
| 227 | + [ |
| 228 | + "spotify:album:3IqzqH6ShrRtie9Yd2ODyG", |
| 229 | + "1A2GTWGtFfWp7KSQTwWOyo", |
| 230 | + "2noRn2Aes5aoNVsU6iWTh", |
| 231 | + ] |
| 232 | + ) |
| 233 | + responses.assert_called_once_with( |
| 234 | + f"{SPOTIFY_URL}/v1/me/albums", |
| 235 | + METH_DELETE, |
| 236 | + headers=HEADERS, |
| 237 | + params={ |
| 238 | + "ids": "3IqzqH6ShrRtie9Yd2ODyG,1A2GTWGtFfWp7KSQTwWOyo,2noRn2Aes5aoNVsU6iWTh" |
| 239 | + }, |
| 240 | + json=None, |
| 241 | + ) |
| 242 | + |
| 243 | + |
| 244 | +async def test_removing_no_saved_albums( |
| 245 | + responses: aioresponses, |
| 246 | + authenticated_client: SpotifyClient, |
| 247 | +) -> None: |
| 248 | + """Test removing no saved albums.""" |
| 249 | + await authenticated_client.remove_saved_albums([]) |
| 250 | + responses.assert_not_called() # type: ignore[no-untyped-call] |
| 251 | + |
| 252 | + |
| 253 | +async def test_removing_too_many_saved_albums( |
| 254 | + responses: aioresponses, |
| 255 | + authenticated_client: SpotifyClient, |
| 256 | +) -> None: |
| 257 | + """Test removing too many saved albums.""" |
| 258 | + with pytest.raises(ValueError, match="Maximum of 50 albums can be removed at once"): |
| 259 | + await authenticated_client.remove_saved_albums(["abc"] * 51) |
| 260 | + responses.assert_not_called() # type: ignore[no-untyped-call] |
| 261 | + |
| 262 | + |
217 | 263 | @pytest.mark.parametrize( |
218 | 264 | "playback_fixture", |
219 | 265 | [ |
|
0 commit comments