def test_context(self):
     "Sends the correct data to the templates"
     accounts = AccountFactory.create_batch(2)
     artists = ArtistFactory.create_batch(3)
     response = self.client.get(reverse('lastfm:artist_list'))
     self.assertIn('account_list', response.context)
     self.assertEqual(len(response.context['account_list']), 2)
     self.assertIn('artist_list', response.context)
     self.assertEqual(len(response.context['artist_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')
Exemple #2
0
    def setUp(self):
        self.artists = ArtistFactory.create_batch(11)
        self.tracks = []
        # Each artist has one track, scrobbled once:
        for artist in self.artists:
            track = TrackFactory(artist=artist)
            self.tracks.append(track)
            ScrobbleFactory(artist=artist, track=track)

        # Extra scrobbles.
        # For tracks[1] will be 1st, tracks[2] will be 2nd:
        ScrobbleFactory.create_batch(2,
                                artist=self.artists[1], track=self.tracks[1])
        ScrobbleFactory.create_batch(1,
                                artist=self.artists[2], track=self.tracks[2])
Exemple #3
0
 def test_context(self):
     "Sends the correct data to the templates"
     accounts = AccountFactory.create_batch(2)
     artists = ArtistFactory.create_batch(3)
     response = self.client.get(reverse('lastfm:artist_list'))
     self.assertIn('account_list', response.context)
     self.assertEqual(len(response.context['account_list']), 2)
     self.assertIn('artist_list', response.context)
     self.assertEqual(len(response.context['artist_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')