Exemplo n.º 1
0
 def test_nxtrack_purge(self):
     self.mpd.clear()
     track = track_from_spotify_url("spotify:track:6LDYVzxjDSAO92UZ5veM3u")
     self.db.session.add(PlayQueueEntry(track=track, mpd_id=0))
     self.db.session.commit()
     _ensure_mpd_playlist_consistency(self.mpd)
     assert len(self.mpd.playlistinfo()) == 0
     assert len(PlayQueueEntry.query.all()) == 0
Exemplo n.º 2
0
 def test_nxtrack_purge(self):
     self.mpd.clear()
     track = track_from_spotify_url("spotify:track:6LDYVzxjDSAO92UZ5veM3u")
     self.db.session.add(PlayQueueEntry(track=track, mpd_id=0))
     self.db.session.commit()
     _ensure_mpd_playlist_consistency(self.mpd)
     assert len(self.mpd.playlistinfo()) == 0
     assert len(PlayQueueEntry.query.all()) == 0
Exemplo n.º 3
0
 def test_track_from_spotify_url(self):
     track = track_from_spotify_url('spotify:track:6LDYVzxjDSAO92UZ5veM3u')
     assert track is not None
     assert track.title == 'Elevator Love Letter'
     assert track.artist == 'Stars'
     assert track.album == 'Heart'
     assert track.length == 243.147
     assert track.date == '2003' or track.date == '2003-01-01'
     assert track.spotify_url == 'spotify:track:6LDYVzxjDSAO92UZ5veM3u'
Exemplo n.º 4
0
 def test_track_from_spotify_url(self):
     track = track_from_spotify_url('spotify:track:6LDYVzxjDSAO92UZ5veM3u')
     assert track is not None
     assert track.title == 'Elevator Love Letter'
     assert track.artist == 'Stars'
     assert track.album == 'Heart'
     assert track.length == 243.147
     assert track.date == '2003' or track.date == '2003-01-01'
     assert track.spotify_url == 'spotify:track:6LDYVzxjDSAO92UZ5veM3u'
Exemplo n.º 5
0
 def setup_track(self):
     self.user_id = self.user.id
     self.queueing_user = self.create_test_user()
     self.queueing_user_id = self.queueing_user.id
     r = random.Random()
     st = r.choice(sample_tracks)
     track = track_from_spotify_url(st['file'])
     self.pqe = PlayQueueEntry(track = track, user=self.queueing_user)
     db.session.add(self.pqe)
     db.session.commit()
Exemplo n.º 6
0
 def setup_track(self):
     self.user_id = self.user.id
     self.queueing_user = self.create_test_user()
     self.queueing_user_id = self.queueing_user.id
     r = random.Random()
     st = r.choice(sample_tracks)
     track = track_from_spotify_url(st['file'])
     self.pqe = PlayQueueEntry(track=track, user=self.queueing_user)
     db.session.add(self.pqe)
     db.session.commit()
Exemplo n.º 7
0
 def add_tracks(self):
     self.user = self.create_test_user()
     self.added_tracks = []
     r = random.Random()
     for i in range(1,100):
         sample_track = r.choice(sample_tracks)
         track_to_add = track_from_spotify_url(sample_track['file'])
         self.added_tracks.append(track_to_add)
         when = datetime.datetime(datetime.MINYEAR, 1, 1, 0, 0, 0, i)
         phe = PlayHistoryEntry(track=track_to_add, user=self.user, time_played=when)
         db.session.add(phe)
     db.session.commit()
Exemplo n.º 8
0
 def add_tracks(self):
     self.user = self.create_test_user()
     self.added_tracks = []
     r = random.Random()
     for i in range(1, 100):
         sample_track = r.choice(sample_tracks)
         track_to_add = track_from_spotify_url(sample_track['file'])
         self.added_tracks.append(track_to_add)
         when = datetime.datetime(datetime.MINYEAR, 1, 1, 0, 0, 0, i)
         phe = PlayHistoryEntry(track=track_to_add,
                                user=self.user,
                                time_played=when)
         db.session.add(phe)
     db.session.commit()
Exemplo n.º 9
0
    def setup_tracks(self):
        self.user = self.create_test_user()

        now = datetime.datetime.now()
        day = datetime.timedelta(hours=5)
        week = datetime.timedelta(days=4)
        month = datetime.timedelta(weeks=3)
        year = datetime.timedelta(weeks=23)
        all_time = datetime.timedelta(weeks=82)

        for time_period in [day, week, month, year, all_time]:
            # Add some tracks from today
            r = random.Random()
            for i in range(1,51):
                st = r.choice(sample_tracks)
                track = track_from_spotify_url(st['file'])
                phe = PlayHistoryEntry(track=track, user=self.user, time_played=now - time_period)
                db.session.add(phe)
        db.session.commit()    
Exemplo n.º 10
0
    def setup_tracks(self):
        self.user = self.create_test_user()

        now = datetime.datetime.now()
        day = datetime.timedelta(hours=5)
        week = datetime.timedelta(days=4)
        month = datetime.timedelta(weeks=3)
        year = datetime.timedelta(weeks=23)
        all_time = datetime.timedelta(weeks=82)

        for time_period in [day, week, month, year, all_time]:
            # Add some tracks from today
            r = random.Random()
            for i in range(1, 51):
                st = r.choice(sample_tracks)
                track = track_from_spotify_url(st['file'])
                phe = PlayHistoryEntry(track=track,
                                       user=self.user,
                                       time_played=now - time_period)
                db.session.add(phe)
        db.session.commit()