mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-10-11 09:10:45 +00:00
Support after/before in current_user_recently_played
This commit is contained in:
1 parent
349587ca32
commit
ff7c33e97d
3 files changed
+32
-2
No files matched your search
@@ -25,6 +25,7 @@ import sys
|
||||
import unittest
|
||||
import warnings
|
||||
import requests
|
||||
from pprint import pprint # noqa
|
||||
|
||||
sys.path.insert(0, os.path.abspath(os.pardir))
|
||||
|
||||
@@ -88,6 +89,7 @@ class AuthTestSpotipy(unittest.TestCase):
|
||||
'user-read-private '
|
||||
'user-top-read '
|
||||
'user-follow-modify '
|
||||
'user-read-recently-played '
|
||||
'ugc-image-upload'
|
||||
)
|
||||
|
||||
@@ -241,6 +243,25 @@ class AuthTestSpotipy(unittest.TestCase):
|
||||
items = response['items']
|
||||
self.assertTrue(len(items) > 0)
|
||||
|
||||
def test_current_user_recently_played(self):
|
||||
# No cursor
|
||||
res = self.spotify.current_user_recently_played()
|
||||
self.assertTrue(len(res['items']) <= 50)
|
||||
played_at = res['items'][0]['played_at']
|
||||
|
||||
# Using `before` gives tracks played before
|
||||
res = self.spotify.current_user_recently_played(
|
||||
before=res['cursors']['after'])
|
||||
self.assertTrue(len(res['items']) <= 50)
|
||||
self.assertTrue(res['items'][0]['played_at'] < played_at)
|
||||
played_at = res['items'][0]['played_at']
|
||||
|
||||
# Using `after` gives tracks played after
|
||||
res = self.spotify.current_user_recently_played(
|
||||
after=res['cursors']['before'])
|
||||
self.assertTrue(len(res['items']) <= 50)
|
||||
self.assertTrue(res['items'][0]['played_at'] > played_at)
|
||||
|
||||
def test_user_playlist_ops(self):
|
||||
sp = self.spotify
|
||||
# create empty playlist
|
||||
|
||||
Reference in new issue
Block a user