def test_create_spotify_tracks_ids_list_from_loved(self): """Method used to test creation of a list of tracks IDs based on given loved tracks dictionaries with usage of spotipy.Spotify object. Created list is compared with expected list (both sorted).""" expected_tracks_ids = ['6NwbeybX6TDtXlpXvnUOZC', '5ahvjrjn7ymaeaWKFZrsca'] tracks_ids = spotify.create_spotify_tracks_ids_list_from_loved(SpotifyTest.loved_tracks, SpotifyTest.spotify_obj) self.assertTrue(sorted(tracks_ids) == sorted(expected_tracks_ids))
def test_create_spotify_tracks_ids_list_from_loved(self): """Method used to test creation of a list of tracks IDs based on given loved tracks dictionaries with usage of spotipy.Spotify object. Created list is compared with expected list (both sorted).""" expected_tracks_ids = [ '6NwbeybX6TDtXlpXvnUOZC', '5ahvjrjn7ymaeaWKFZrsca' ] tracks_ids = spotify.create_spotify_tracks_ids_list_from_loved( SpotifyTest.loved_tracks, SpotifyTest.spotify_obj) self.assertTrue(sorted(tracks_ids) == sorted(expected_tracks_ids))
def lastfm_fav_to_spotify_playlist(): """Main method of the project that brings together other modules that are using APIs.""" (loved_tracks, spotify_username, playlist_name) = extract_variables() try: token = spotify.generate_token() except spotify.TokenGenerationException: print('Error generating token.') # GUI => dialog window else: sp = spotify.create_spotify_object(token) tracks_ids = spotify.create_spotify_tracks_ids_list_from_loved(loved_tracks, sp) playlist_id = spotify.create_playlist_for_user(sp, spotify_username, playlist_name) spotify.add_tracks_to_playlist(sp, spotify_username, playlist_id, tracks_ids)