Exemplo n.º 1
0
 def test_get_top_albums_limit(self):
     "Only returns the number of top albums requested"
     artist = ArtistFactory()
     albums = AlbumFactory.create_batch(4, artist=artist)
     tracks = TrackFactory.create_batch(4, artist=artist)
     for idx, t in enumerate(tracks):
         ScrobbleFactory(artist=artist, track=t, album=albums[idx])
     top_albums = artist.get_top_albums(limit=3)
     self.assertEqual(len(top_albums), 3)
Exemplo n.º 2
0
 def test_get_top_albums(self):
     "Returns all albums, ordered by most-scrobbled first"
     artist = ArtistFactory()
     albums = AlbumFactory.create_batch(3, artist=artist)
     # NB, Tracks & Albums are only associated via Scrobbles, not directly:
     tracks = TrackFactory.create_batch(3, artist=artist)
     # Scrobble all tracks+albums once...
     for idx, t in enumerate(tracks):
         ScrobbleFactory(artist=artist, track=t, album=albums[idx])
     # ... but scrobble one of them an additional time:
     ScrobbleFactory(artist=artist, track=tracks[1], album=albums[1])
     top_albums = artist.get_top_albums()
     self.assertEqual(len(top_albums), 3)
     self.assertEqual(top_albums[0], albums[1])