def test_updateBDDfromSpotify(self): objapi=APISFY("credenciales.txt") objbdd=DBSFY('Arma_tu_biblio.db') objsync=sinchronize() ids=objapi.getPlaylistsIDSfromSpotify() #print("getPlaylistfromSpotify berfore delete",ids) #tracks=objapi.getTrackslistfromSpotify() try: tracksid=[] print(objbdd.deleteAllTracks()) # para prueba print(objapi.deleteTrack(ids)) # para prueba track1=objapi.getTrackfromSpotify('Dare','Gorillaz') tracksid.append(track1.id) #print(track1) track2=objapi.getTrackfromSpotify('Get lucky','Daft Punk') tracksid.append(track2.id) objapi.saveTrack(tracksid) #se guardaron los dos para la prueba print("tracks saved\nPlaylist spotify:\n") # play=objapi.getTrackslistfromSpotify() print(objapi.printPlaylist(play)) print("***************************************") self.assertEqual(0,objsync.updateBDDfromSpotify(play,objbdd)) bddplaylist=objbdd.getPlaylistFromDB() print(len(bddplaylist)) print(objapi.printPlaylist(bddplaylist)) except: print("Error en test_updateBDDfromSpotify")
def test_checkBDDvsSpotify(self): id_prueba1='58MZs0B5Amxl0Mwc9FIRZc' id_prueba2='64Mgiyn0JSji95v7QEOv4U' a=APISFY("credenciales.txt") s=sinchronize() #d=DBSFY("./../Arma_tu_biblio.db") #idsSp=a.getPlaylistfromSpotify() idsSp=[id_prueba1,id_prueba2]#d.getPlaylistFromDB() idsBDD=[id_prueba1,id_prueba2] print (idsBDD) print(idsSp) print(s.checkBDDvsSpotify(idsSp,idsBDD))
def test_updateSpotifyfromBDD(self): class Mock_Track: def __init__(self, id, name, artist, album, duration): self.id = id self.name = name self.artist = artist self.album = album self.duration = duration mock1 = Mock_Track('08jkW1RWXUwKA3W0bqWGuU', 'Get Lucky - Karaoke', 'Tribute to Daft Punk', 'Get Lucky', 258101) mock2 = Mock_Track('58MZs0B5Amxl0Mwc9FIRZc', 'DARE - Junior Sanchez Remix', 'Gorillaz', 'D-Sides [Special Edition]', 326373) objapi = APISFY("credenciales.txt") objbdd = DBSFY('Arma_tu_biblio_test.db') objsync = sinchronize() idsSp = objapi.getPlaylistsIDSfromSpotify() print("getPlaylistfromSpotify berfore delete", idsSp) try: print("Borrando playlist de spotify...") objapi.deleteTrack(idsSp) print("Borrado") print("Borrando base de datos...") objbdd.deleteAllTracks() print("Borrada") bddlist = objbdd.getPlaylistFromDB() if len(bddlist) < 1: print("lista vacia") objbdd.saveTrack(mock1) objbdd.saveTrack(mock2) print("Tracks added to db") playlistbdd = objbdd.getPlaylistFromDB() ids = objbdd.getIDSFromDB(playlistbdd) print(ids) print(objsync.updateSpotifyfromBDD(objapi, ids)) ids = objapi.getPlaylistsIDSfromSpotify() print("getPlaylistfromSpotify ", ids) else: print("hey i love you") except: print("Error in test_updateSpotifyfromBDD")
def __init__(self,credentialsFilePath,BDDFIlePath ): self.sync=sinchronize() self.bdd=DBSFY(BDDFIlePath) self.api=APISFY(credentialsFilePath) self.makeSync() print()