Beispiel #1
0
    def setUp(self):
        self.artist1 = ArtistFactory()
        self.tracks = TrackFactory.create_batch(11, artist=self.artist1)
        self.albums = AlbumFactory.create_batch(11, artist=self.artist1)
        # Scrobble each album/track once:
        for idx, track in enumerate(self.tracks):
            ScrobbleFactory(artist=self.artist1,
                            track=track,
                            album=self.albums[idx])

        # Extra scrobbles.
        # For artist1, tracks[1] will be 1st, tracks[2] will be 2nd:
        ScrobbleFactory.create_batch(2,
                                     artist=self.artist1,
                                     track=self.tracks[1],
                                     album=self.albums[1])
        ScrobbleFactory.create_batch(1,
                                     artist=self.artist1,
                                     track=self.tracks[2],
                                     album=self.albums[2])

        # But artist2 has a more scrobbled album:
        self.artist2 = ArtistFactory()
        self.track2 = TrackFactory(artist=self.artist2)
        self.album2 = AlbumFactory(artist=self.artist2)
        ScrobbleFactory.create_batch(4,
                                     artist=self.artist2,
                                     track=self.track2,
                                     album=self.album2)
Beispiel #2
0
 def test_get_top_tracks_limit(self):
     "Only returns the number of top tracks requested"
     artist = ArtistFactory()
     tracks = TrackFactory.create_batch(4, artist=artist)
     for t in tracks:
         ScrobbleFactory(artist=artist, track=t)
     top_tracks = artist.get_top_tracks(limit=3)
     self.assertEqual(len(top_tracks), 3)
Beispiel #3
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)
Beispiel #4
0
 def test_get_top_tracks(self):
     "Returns all tracks, ordered by most-scrobbled first"
     artist = ArtistFactory()
     tracks = TrackFactory.create_batch(3, artist=artist)
     # Scrobble all tracks once...
     for t in tracks:
         ScrobbleFactory(artist=artist, track=t)
     # ... but scrobble one of them an additional time:
     ScrobbleFactory(artist=artist, track=tracks[1])
     top_tracks = artist.get_top_tracks()
     self.assertEqual(len(top_tracks), 3)
     self.assertEqual(top_tracks[0], tracks[1])
Beispiel #5
0
 def test_context(self):
     "Sends the correct data to the templates"
     accounts = AccountFactory.create_batch(2)
     tracks = TrackFactory.create_batch(3)
     response = self.client.get(reverse('lastfm:track_list'))
     self.assertIn('account_list', response.context)
     self.assertEqual(len(response.context['account_list']), 2)
     self.assertIn('track_list', response.context)
     self.assertEqual(len(response.context['track_list']), 3)
     self.assertIn('valid_days', response.context)
     self.assertEqual(response.context['valid_days'],
                     ['7', '30', '90', '180', '365', 'all',])
     self.assertIn('current_days', response.context)
     self.assertEqual(response.context['current_days'], 'all')
Beispiel #6
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])
Beispiel #7
0
    def setUp(self):
        self.album1 = AlbumFactory()
        self.artist1 = ArtistFactory()
        self.tracks = TrackFactory.create_batch(11, artist=self.artist1)
        # Extra scrobbles.
        # For artist1, tracks[1] will be 1st, tracks[2] will be 2nd:
        ScrobbleFactory.create_batch(2,
                album=self.album1, artist=self.artist1, track=self.tracks[1])
        ScrobbleFactory.create_batch(1,
                album=self.album1, artist=self.artist1, track=self.tracks[2])

        # But artist2 has a more-scrobbled Track:
        self.album2 = AlbumFactory()
        self.artist2 = ArtistFactory()
        self.track2 = TrackFactory(artist=self.artist2)
        ScrobbleFactory.create_batch(4,
                album=self.album2, artist=self.artist2, track=self.track2)
Beispiel #8
0
 def test_context(self):
     "Sends the correct data to the templates"
     accounts = AccountFactory.create_batch(2)
     tracks = TrackFactory.create_batch(3)
     response = self.client.get(reverse('lastfm:track_list'))
     self.assertIn('account_list', response.context)
     self.assertEqual(len(response.context['account_list']), 2)
     self.assertIn('track_list', response.context)
     self.assertEqual(len(response.context['track_list']), 3)
     self.assertIn('valid_days', response.context)
     self.assertEqual(response.context['valid_days'], [
         '7',
         '30',
         '90',
         '180',
         '365',
         'all',
     ])
     self.assertIn('current_days', response.context)
     self.assertEqual(response.context['current_days'], 'all')
    def setUp(self):
        self.artist1 = ArtistFactory()
        self.tracks = TrackFactory.create_batch(11, artist=self.artist1)
        self.albums = AlbumFactory.create_batch(11, artist=self.artist1)
        # Scrobble each album/track once:
        for idx, track in enumerate(self.tracks):
            ScrobbleFactory(artist=self.artist1,
                            track=track,
                            album=self.albums[idx])

        # Extra scrobbles.
        # For artist1, tracks[1] will be 1st, tracks[2] will be 2nd:
        ScrobbleFactory.create_batch(2, artist=self.artist1,
                                    track=self.tracks[1], album=self.albums[1])
        ScrobbleFactory.create_batch(1, artist=self.artist1,
                                    track=self.tracks[2], album=self.albums[2])

        # But artist2 has a more scrobbled album:
        self.artist2 = ArtistFactory()
        self.track2 = TrackFactory(artist=self.artist2)
        self.album2 = AlbumFactory(artist=self.artist2)
        ScrobbleFactory.create_batch(4, artist=self.artist2,
                                track=self.track2, album=self.album2)