Пример #1
0
 def test_get_most_recent_scrobble(self):
     artist = ArtistFactory()
     scrobble1 = ScrobbleFactory(artist=artist,
                         post_time=datetime_from_str('2015-08-11 12:00:00'))
     scrobble2 = ScrobbleFactory(artist=artist,
                         post_time=datetime_from_str('2015-08-12 12:00:00'))
     self.assertEqual(artist.get_most_recent_scrobble(), scrobble2)
Пример #2
0
    def setUp(self):
        bob = AccountFactory(username='******')
        terry = AccountFactory(username='******')

        self.artist1 = ArtistFactory()
        self.track1 = TrackFactory(artist=self.artist1)
        self.album1 = AlbumFactory(artist=self.artist1)

        self.artist2 = ArtistFactory()
        self.track2 = TrackFactory(artist=self.artist2)

        bobs1 = ScrobbleFactory.create_batch(2,
                                             account=bob,
                                             track=self.track1,
                                             artist=self.artist1,
                                             album=self.album1)
        bobs2 = ScrobbleFactory.create_batch(5,
                                             account=bob,
                                             track=self.track2,
                                             artist=self.artist2)

        terrys1 = ScrobbleFactory.create_batch(3,
                                               account=terry,
                                               track=self.track1,
                                               artist=self.artist1,
                                               album=self.album1)
        terrys2 = ScrobbleFactory.create_batch(7,
                                               account=terry,
                                               track=self.track2,
                                               artist=self.artist2)
Пример #3
0
    def setUp(self):
        artist = ArtistFactory()
        track = TrackFactory(artist=artist)
        album = AlbumFactory(artist=artist)

        # Scrobbled 4 times on different days, by 2 different Accounts:
        scrobble1 = ScrobbleFactory(
            artist=artist,
            track=track,
            album=album,
            post_time=datetime_from_str('2015-08-11 12:00:00'))
        scrobble2 = ScrobbleFactory(
            artist=artist,
            track=track,
            album=album,
            post_time=datetime_from_str('2015-08-12 12:00:00'))
        scrobble2 = ScrobbleFactory(
            artist=artist,
            track=track,
            album=album,
            post_time=datetime_from_str('2015-08-13 12:00:00'))
        scrobble4 = ScrobbleFactory(
            artist=artist,
            track=track,
            album=album,
            post_time=datetime_from_str('2015-08-14 12:00:00'))
Пример #4
0
 def test_get_scrobble_count(self):
     artist = ArtistFactory()
     track = TrackFactory(artist=artist)
     # Scrobbled 2 times:
     ScrobbleFactory.create_batch(2, artist=artist, track=track)
     # And another Scrobble with different artist/track:
     ScrobbleFactory()
     self.assertEqual(track.get_scrobble_count(), 2)
Пример #5
0
 def test_recent_scrobbles_order(self):
     "It returns the most recent first"
     account = AccountFactory()
     scrobble1 = ScrobbleFactory(account=account,
                         post_time=datetime_from_str('2015-08-11 12:00:00'))
     scrobble2 = ScrobbleFactory(account=account,
                         post_time=datetime_from_str('2015-08-12 12:00:00'))
     self.assertEqual(account.get_recent_scrobbles()[0], scrobble2)
Пример #6
0
 def test_recent_scrobbles_correct_account(self):
     "It only returns scrobbles for itself, not another account"
     account1 = AccountFactory()
     account2 = AccountFactory()
     scrobble1 = ScrobbleFactory(account=account1)
     scrobble2 = ScrobbleFactory(account=account2)
     scrobbles = account1.get_recent_scrobbles()
     self.assertEqual(len(scrobbles), 1)
     self.assertEqual(scrobbles[0], scrobble1)
Пример #7
0
 def test_get_most_recent_scrobble(self):
     artist = ArtistFactory()
     track = TrackFactory(artist=artist)
     album = AlbumFactory(artist=artist)
     scrobble1 = ScrobbleFactory(artist=artist, track=track, album=album,
                         post_time=datetime_from_str('2015-08-11 12:00:00'))
     scrobble2 = ScrobbleFactory(artist=artist, track=track, album=album,
                         post_time=datetime_from_str('2015-08-12 12:00:00'))
     self.assertEqual(album.get_most_recent_scrobble(), scrobble2)
Пример #8
0
 def test_ordering(self):
     "It should order by post_time descending."
     scrobble_1 = ScrobbleFactory(
                         post_time=datetime_from_str('2015-08-11 12:00:00'))
     scrobble_2 = ScrobbleFactory(
                         post_time=datetime_from_str('2015-08-12 12:00:00'))
     scrobbles = Scrobble.objects.all()
     self.assertEqual(scrobbles[0], scrobble_2)
     self.assertEqual(scrobbles[1], scrobble_1)
Пример #9
0
 def test_args_track(self):
     "Should only return Scrobbles on Albums featuring supplied Track"
     album2 = AlbumFactory()
     track2 = TrackFactory()
     ScrobbleFactory(album=album2, track=track2)
     ScrobbleFactory(album=album2, track=track2)
     albums = Album.objects.with_scrobble_counts(track=track2)
     self.assertEqual(len(albums), 1)
     self.assertEqual(len(albums), 1)
     self.assertEqual(albums[0], album2)
     self.assertEqual(albums[0].scrobble_count, 2)
Пример #10
0
 def test_context(self):
     "Sends the correct data to the templates"
     accounts = AccountFactory.create_batch(3)
     scrobble1 = ScrobbleFactory(account=accounts[0])
     scrobble2 = ScrobbleFactory(account=accounts[1])
     response = self.client.get(reverse('lastfm:home'))
     self.assertIn('account_list', response.context)
     self.assertEqual(len(response.context['account_list']), 3)
     self.assertIn('counts', response.context)
     self.assertIn('scrobbles', response.context['counts'])
     self.assertEqual(response.context['counts']['scrobbles'], 2)
Пример #11
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])
Пример #12
0
    def test_data(self):
        account = LastfmAccountFactory(username='******')
        ScrobbleFactory.create_batch(3,
                                account=account,
                                post_time=make_datetime('2018-01-01 12:00:00'))

        result = LastfmGenerator(username='******').get_scrobbles_per_year()

        self.assertIn('data', result)
        self.assertEqual(len(result['data']), 1)
        self.assertEqual(result['data'][0]['label'], '2018')
        self.assertEqual(result['data'][0]['value'], 3)
Пример #13
0
 def setUp(self):
     self.account1 = AccountFactory()
     self.account2 = AccountFactory()
     # Some for account1 in 2015 and 2016:
     scrobbles1 = ScrobbleFactory.create_batch(3,
                         post_time=datetime_from_str('2015-01-01 12:00:00'),
                         account=self.account1)
     scrobbles2 = ScrobbleFactory.create_batch(2,
                         post_time=datetime_from_str('2016-01-01 12:00:00'),
                         account=self.account1)
     # And one for account2 in 2015:
     scrobble3 = ScrobbleFactory(account=self.account2,
                         post_time=datetime_from_str('2015-01-01 12:00:00'))
Пример #14
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])
Пример #15
0
 def test_default_days(self):
     "Has correct scrobble count context when all days are viewed, the default."
     artist = ArtistFactory()
     album = AlbumFactory(artist=artist)
     scrobble1 = ScrobbleFactory(
         artist=artist,
         album=album,
         post_time=datetime_from_str('2012-10-01 12:00:00'))
     scrobble2 = ScrobbleFactory(
         artist=artist,
         album=album,
         post_time=datetime_from_str('2016-10-01 12:00:00'))
     response = self.client.get(reverse('lastfm:album_list'))
     self.assertEqual(response.context['album_list'][0].scrobble_count, 2)
Пример #16
0
 def test_args_album(self):
     "Only aggregates scrobble_counts for a particular album."
     artist2 = ArtistFactory()
     album1 = AlbumFactory()
     album2 = AlbumFactory()
     track = TrackFactory()
     ScrobbleFactory(album=album1, artist=self.artist, track=track)
     ScrobbleFactory(album=album1, artist=self.artist, track=track)
     ScrobbleFactory(album=album1, artist=artist2, track=track)
     ScrobbleFactory(album=album2, artist=self.artist, track=track)
     artists = Artist.objects.with_scrobble_counts(album=album1)
     self.assertEqual(len(artists), 2)
     self.assertEqual(artists[0].scrobble_count, 2)
     self.assertEqual(artists[1].scrobble_count, 1)
Пример #17
0
 def test_7_days(self):
     "Has correct scrobble count context when a restricted number of days are viewed."
     artist = ArtistFactory()
     track = TrackFactory(artist=artist)
     scrobble1 = ScrobbleFactory(
         artist=artist,
         track=track,
         post_time=datetime_from_str('2012-10-01 12:00:00'))
     scrobble2 = ScrobbleFactory(
         artist=artist,
         track=track,
         post_time=datetime_from_str('2016-10-01 12:00:00'))
     response = self.client.get("%s?days=7" % reverse('lastfm:track_list'))
     self.assertEqual(response.context['track_list'][0].scrobble_count, 1)
Пример #18
0
    def test_for_day_with_date(self):
        "Should return only albums from the requested day, using date."
        # 2 scrobbles on this day:
        ScrobbleFactory(track=self.tracks[1], album=self.albums[1],
                        post_time=datetime_from_str('2016-10-01 00:00:00'))
        ScrobbleFactory(track=self.tracks[1], album=self.albums[1],
                        post_time=datetime_from_str('2016-10-01 23:59:59'))
        # 1 scrobble on this day:
        ScrobbleFactory(track=self.tracks[2], album=self.albums[2],
                        post_time=datetime_from_str('2016-10-02 12:00:00'))

        albums = ditto_lastfm.top_albums(period='day',
                        date=datetime_from_str('2016-10-01 00:00:00').date())
        self.assertEqual(len(albums), 1)
        self.assertEqual(albums[0].scrobble_count, 2)
Пример #19
0
    def test_for_year(self):
        "Should return only tracks from the requested year."
        # 2 scrobbles in this year:
        ScrobbleFactory(track=self.tracks[1],
                        post_time=datetime_from_str('2015-01-01 12:00:00'))
        ScrobbleFactory(track=self.tracks[1],
                        post_time=datetime_from_str('2015-12-31 12:00:00'))
        # 1 scrobble in this year:
        ScrobbleFactory(track=self.tracks[2],
                        post_time=datetime_from_str('2016-03-01 12:00:00'))

        tracks = ditto_lastfm.top_tracks(period='year',
                        date=datetime_from_str('2015-09-01 00:00:00'))
        self.assertEqual(len(tracks), 1)
        self.assertEqual(tracks[0].scrobble_count, 2)
Пример #20
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])
Пример #21
0
    def test_for_month(self):
        "Should return only tracks from the requested month."
        # 2 scrobbles in this month:
        ScrobbleFactory(track=self.tracks[1],
                        post_time=datetime_from_str('2016-09-01 12:00:00'))
        ScrobbleFactory(track=self.tracks[1],
                        post_time=datetime_from_str('2016-09-30 12:00:00'))
        # 1 scrobble in this month:
        ScrobbleFactory(track=self.tracks[2],
                        post_time=datetime_from_str('2016-10-01 12:00:00'))

        tracks = ditto_lastfm.top_tracks(period='month',
                        date=datetime_from_str('2016-09-15 00:00:00'))
        self.assertEqual(len(tracks), 1)
        self.assertEqual(tracks[0].scrobble_count, 2)
Пример #22
0
 def test_args_account(self):
     "Should only return Scrobbles by supplied Account"
     account = AccountFactory()
     scrobble2 = ScrobbleFactory(artist=self.artist, account=account)
     artists = Artist.objects.with_scrobble_counts(account=account)
     self.assertEqual(len(artists), 1)
     self.assertEqual(artists[0].scrobble_count, 1)
Пример #23
0
 def test_long_titles(self):
     "If artist + track is longer than 255 characters, it gets truncated."
     a = ArtistFactory(name='Drew Danburry')
     t = TrackFactory(artist=a, name="Jerry Spinelli and Patricia Polacco or Every Moment of Every Day We Are Faced With the Decision as to Whether We Will Continue Doing What We Are Doing or Choose a Different Way to Do Things. This, Essentially, Means That It Is Also Our Fault When...")
     scrobble = ScrobbleFactory(artist=a, track=t)
     self.maxDiff = None # To show the full diff.
     self.assertEqual(scrobble.title, "Drew Danburry – Jerry Spinelli and Patricia Polacco or Every Moment of Every Day We Are Faced With the Decision as to Whether We Will Continue Doing What We Are Doing or Choose a Different Way to Do Things. This, Essentially, Means That It Is Also Our…")
Пример #24
0
    def test_albums(self):
        artist = ArtistFactory()
        track = TrackFactory(artist=artist)
        album1 = AlbumFactory(artist=artist)
        album2 = AlbumFactory(artist=artist)
        # Scrobble album1 once, album2 twice:
        ScrobbleFactory(artist=artist, track=track, album=album1)
        ScrobbleFactory(artist=artist, track=track, album=album2)
        ScrobbleFactory(artist=artist, track=track, album=album2)

        albums = track.albums
        self.assertEqual(len(albums), 2)
        self.assertEqual(albums[0], album2)
        self.assertEqual(albums[1], album1)
        self.assertEqual(albums[0].scrobble_count, 2)
        self.assertEqual(albums[1].scrobble_count, 1)
Пример #25
0
    def test_for_week_sunday_start(self):
        "Should return only albums from the requested week (Sunday start)."
        # 2 scrobble in this week:
        # 2017-09-03 is a Sunday
        ScrobbleFactory(track=self.tracks[1], album=self.albums[1],
                        post_time=datetime_from_str('2017-09-03 12:00:00'))
        ScrobbleFactory(track=self.tracks[1], album=self.albums[1],
                        post_time=datetime_from_str('2017-09-09 12:00:00'))
        # 1 scrobble in this week:
        ScrobbleFactory(track=self.tracks[2], album=self.albums[2],
                        post_time=datetime_from_str('2017-09-10 12:00:00'))

        albums = ditto_lastfm.top_albums(period='week',
                        date=datetime_from_str('2017-09-07 00:00:00'))
        self.assertEqual(len(albums), 1)
        self.assertEqual(albums[0].scrobble_count, 2)
Пример #26
0
    def test_for_week_sunday_start(self):
        "Should return only artists from the requested week (Sunday start)."
        # 2 scrobbles on this day:
        # 2017-09-03 is a Sunday
        ScrobbleFactory(track=self.tracks[1], artist=self.artists[1],
                        post_time=datetime_from_str('2017-09-03 00:00:00'))
        ScrobbleFactory(track=self.tracks[1], artist=self.artists[1],
                        post_time=datetime_from_str('2017-09-09 23:59:59'))
        # 1 scrobble on this day:
        ScrobbleFactory(track=self.tracks[2], artist=self.artists[2],
                        post_time=datetime_from_str('2017-09-10 12:00:00'))

        artists = ditto_lastfm.top_artists(period='week',
                        date=datetime_from_str('2017-09-07 00:00:00'))
        self.assertEqual(len(artists), 1)
        self.assertEqual(artists[0].scrobble_count, 2)
Пример #27
0
    def test_tracks(self):
        artist = ArtistFactory()
        track1 = TrackFactory(artist=artist)
        track2 = TrackFactory(artist=artist)
        album = AlbumFactory(artist=artist)
        # Scrobble track1 once, track2 twice:
        ScrobbleFactory(artist=artist, track=track1, album=album)
        ScrobbleFactory(artist=artist, track=track2, album=album)
        ScrobbleFactory(artist=artist, track=track2, album=album)

        tracks = album.tracks
        self.assertEqual(len(tracks), 2)
        self.assertEqual(tracks[0], track2)
        self.assertEqual(tracks[1], track1)
        self.assertEqual(tracks[0].scrobble_count, 2)
        self.assertEqual(tracks[1].scrobble_count, 1)
Пример #28
0
    def test_for_week_monday_start(self):
        "Should return only tracks from the requested week (Monday start)."
        # 2 scrobbles on this day:
        # 2017-09-04 is a Monday
        ScrobbleFactory(track=self.tracks[1],
                        post_time=datetime_from_str('2017-09-04 00:00:00'))
        ScrobbleFactory(track=self.tracks[1],
                        post_time=datetime_from_str('2017-09-10 23:59:59'))
        # 1 scrobble on this day:
        ScrobbleFactory(track=self.tracks[2],
                        post_time=datetime_from_str('2017-09-11 12:00:00'))

        tracks = ditto_lastfm.top_tracks(period='week',
                        date=datetime_from_str('2017-09-07 00:00:00'))
        self.assertEqual(len(tracks), 1)
        self.assertEqual(tracks[0].scrobble_count, 2)
Пример #29
0
 def setUp(self):
     self.account1 = AccountFactory()
     self.account2 = AccountFactory()
     # Some for account1 on 1st Oct:
     self.scrobble1 = ScrobbleFactory(
                         post_time=datetime_from_str('2016-10-01 12:00:00'),
                         account=self.account1)
     self.scrobble2 = ScrobbleFactory(
                         post_time=datetime_from_str('2016-10-01 12:05:00'),
                         account=self.account1)
     # One for account1 on 2nd Oct:
     self.scrobble3 = ScrobbleFactory(
                         post_time=datetime_from_str('2016-10-02 00:00:01'),
                         account=self.account1)
     # And one for account2 on 1st Oct:
     self.scrobble4 = ScrobbleFactory(account=self.account2,
                         post_time=datetime_from_str('2016-10-01 13:00:00'))
Пример #30
0
 def test_empty_years(self):
     "It should include years for which there are no scrobbles."
     # Add a scrobble in 2018, leaving a gap for 2017:
     ScrobbleFactory(post_time=datetime_from_str('2018-01-01 12:00:00'))
     scrobbles = ditto_lastfm.annual_scrobble_counts()
     self.assertEqual(len(scrobbles), 4)
     self.assertEqual(scrobbles[2]['year'], 2017)
     self.assertEqual(scrobbles[2]['count'], 0)
Пример #31
0
 def test_args_account(self):
     "Should only return Scrobbles by supplied Account"
     account = AccountFactory()
     album2 = AlbumFactory()
     scrobble2 = ScrobbleFactory(account=account, album=album2)
     albums = Album.objects.with_scrobble_counts(account=account)
     self.assertEqual(len(albums), 1)
     self.assertEqual(albums[0], album2)
Пример #32
0
    def setUp(self):
        bob = AccountFactory(username='******')
        terry = AccountFactory(username='******')

        self.artist1 = ArtistFactory()
        self.track1 = TrackFactory(artist=self.artist1)
        self.album1 = AlbumFactory(artist=self.artist1)

        self.artist2 = ArtistFactory()
        self.track2 = TrackFactory(artist=self.artist2)

        bobs1 = ScrobbleFactory.create_batch(2, account=bob,
                    track=self.track1, artist=self.artist1, album=self.album1)
        bobs2 = ScrobbleFactory.create_batch(5, account=bob,
                    track=self.track2, artist=self.artist2)

        terrys1 = ScrobbleFactory.create_batch(3, account=terry,
                    track=self.track1, artist=self.artist1, album=self.album1)
        terrys2 = ScrobbleFactory.create_batch(7, account=terry,
                    track=self.track2, artist=self.artist2)
Пример #33
0
    def test_years(self):
        "Should include all intermediate years."
        account = LastfmAccountFactory(username='******')
        ScrobbleFactory(account=account,
                        post_time=make_datetime('2014-01-01 12:00:00'))
        ScrobbleFactory.create_batch(3,
                                account=account,
                                post_time=make_datetime('2016-01-01 12:00:00'))
        ScrobbleFactory(account=account,
                        post_time=make_datetime('2018-01-01 12:00:00'))

        result = LastfmGenerator(username='******').get_scrobbles_per_year()

        self.assertIn('data', result)
        self.assertEqual(result['data'], [
            {'label': '2014', 'value': 1},
            {'label': '2015', 'value': 0},
            {'label': '2016', 'value': 3},
            {'label': '2017', 'value': 0},
            {'label': '2018', 'value': 1},
        ])
Пример #34
0
 def test_args_album(self):
     "Only aggregates scrobble_counts in supplied album."
     album1 = AlbumFactory()
     album2 = AlbumFactory()
     track1 = TrackFactory()
     ScrobbleFactory.create_batch(2, album=album1, track=self.track)
     ScrobbleFactory.create_batch(1, album=album1, track=track1)
     ScrobbleFactory.create_batch(1, album=album2, track=self.track)
     tracks = Track.objects.with_scrobble_counts(album=album1)
     self.assertEqual(len(tracks), 2)
     self.assertEqual(tracks[0].scrobble_count, 2)
     self.assertEqual(tracks[0], self.track)
     self.assertEqual(tracks[1].scrobble_count, 1)
     self.assertEqual(tracks[1], track1)
Пример #35
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)
Пример #36
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)
Пример #37
0
 def test_get_scrobble_count(self):
     artist = ArtistFactory()
     scrobbles = ScrobbleFactory.create_batch(3, artist=artist)
     self.assertEqual(artist.get_scrobble_count(), 3)
Пример #38
0
 def test_recent_scrobbles(self):
     "By default it returns 10 scrobbles"
     account = AccountFactory()
     scrobbles = ScrobbleFactory.create_batch(11, account=account)
     self.assertEqual(len(account.get_recent_scrobbles()), 10)
Пример #39
0
 def setUp(self):
     self.account1 = AccountFactory()
     self.account2 = AccountFactory()
     scrobbles1 = ScrobbleFactory.create_batch(11, account=self.account1)
     self.scrobble2 = ScrobbleFactory(account=self.account2)
Пример #40
0
 def test_recent_scrobbles_limit(self):
     "It returns `limit` scrobbles"
     account = AccountFactory()
     scrobbles = ScrobbleFactory.create_batch(5, account=account)
     self.assertEqual(len(account.get_recent_scrobbles(limit=3)), 3)