Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_argument_chain(self):
func = MagicMock(side_effect=[0, 1])
slf = mock_spotify()
dec = chunked('a', 1, 10, return_last, chain='ch', chain_pos=2)(func)
r = dec(slf, list(range(20)), ch=None)
func.assert_called_with(slf, list(range(10, 20)), ch=0)
assert r == 1
def test_reverse_when_rev_argument_specified(self):
func = MagicMock(side_effect=[0, 1])
slf = mock_spotify()
dec = chunked('a', 1, 10, return_last, reverse='rev', reverse_pos=2)(func)
r = dec(slf, list(range(20)), rev=1)
func.assert_called_with(slf, list(range(10)), rev=1)
assert r == 1
def test_chunked_as_kwarg(self):
func = MagicMock(side_effect=[0, 1])
dec = chunked('a', 2, 10, return_last)(func)
r = dec(mock_spotify(), 0, a=list(range(20)))
assert r == 1
@chunked('user_ids', 1, 50, join_lists)
@send_and_process(nothing)
def users_is_following(self, user_ids: list) -> List[bool]:
"""
Check if current user follows users.
Parameters
----------
user_ids
list of user IDs, max 50 without chunking
Returns
-------
List[bool]
follow statuses in the same order that the user IDs were given
"""
return self._get(
@chunked('track_ids', 1, 50, join_lists)
@send_and_process(model_list(FullTrack, 'tracks'))
def tracks(
self,
track_ids: list,
market: str = None
) -> ModelList[FullTrack]:
"""
Get information for multiple tracks.
Parameters
----------
track_ids
the track IDs, max 50 without chunking
market
an ISO 3166-1 alpha-2 country code or 'from_token'
"""
@chunked('album_ids', 1, 50, return_none)
@send_and_process(nothing)
def saved_albums_delete(self, album_ids: list) -> None:
"""
Remove albums for current user.
Parameters
----------
album_ids
list of album IDs, max 50 without chunking
"""
return self._delete('me/albums?ids=' + ','.join(album_ids))
@chunked('artist_ids', 1, 50, return_none)
@send_and_process(nothing)
def artists_unfollow(self, artist_ids: list) -> None:
"""
Unfollow artists as current user.
Parameters
----------
artist_ids
list of artist IDs, max 50 without chunking
"""
return self._delete('me/following', type='artist', ids=','.join(artist_ids))
@chunked('show_ids', 1, 50, return_none)
@send_and_process(nothing)
def saved_shows_delete(self, show_ids: list, market: str = None) -> None:
"""
Remove shows for current user.
Parameters
----------
show_ids
list of show IDs, max 50 without chunking
market
an ISO 3166-1 alpha-2 country code, only remove shows that are
available in the specified market, overrided by token's country
"""
return self._delete('me/shows/?ids=' + ','.join(show_ids), market=market)
@chunked('track_ids', 1, 50, return_none)
@send_and_process(nothing)
def saved_tracks_add(self, track_ids: list) -> None:
"""
Save tracks for current user.
Parameters
----------
track_ids
list of track IDs, max 50 without chunking
"""
return self._put('me/tracks/?ids=' + ','.join(track_ids))