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)
def test_2_create_spotify_object(self): """Method testing spotipy.Spotify object creation. Needs to be run as second, because generated object is used in further tests.""" SpotifyTest.spotify_obj = spotify.create_spotify_object(self.token) self.assertIsNotNone(SpotifyTest.spotify_obj)