import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '../djagitit/api')) import spotify album_uri = '1cCAb1vN8uUsdfEylVmTLs' scope = 'user-read-recently-played' class TestSpotify: def test_simpleAuth(self): sp = spotify.connect_spotify() album = sp.album(album_uri) assert isinstance(album, dict), f'Expected an instance of dict, got type {type(album)}' assert len(album.get('tracks').get('items')) == 16, 'The Infamous... album should have 16 tracks' def test_scopeAuth(self, SCOPE=scope): sp = spotify.connect_spotify(SCOPE=SCOPE) played = sp.current_user_recently_played(limit=10) assert isinstance(played, dict), f'Expected an instance of dict, got type {type(played)}' assert len(played.get('items')) == 10, f'The call was supposed to return the last 10 tracks played and returned {len(played.get("items"))} results'