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)
def setUp(self): self.user_1 = UserFactory(screen_name='terry') self.user_2 = UserFactory(screen_name='bob') self.user_3 = UserFactory(screen_name='thelma', is_private=True) self.account_1 = AccountFactory(user=self.user_1) account_2 = AccountFactory(user=self.user_2) account_3 = AccountFactory(user=self.user_3) # private # Public tweets in 2015 and 2016: tweets2015 = TweetFactory.create_batch(3, post_time=datetime_from_str('2015-01-01 12:00:00')) tweets2016 = TweetFactory.create_batch(2, post_time=datetime_from_str('2016-01-01 12:00:00')) # One private tweet in 2015: private_tweet = TweetFactory( post_time=datetime_from_str('2015-01-01 12:00:00')) private_tweet.user.is_private = True private_tweet.user.save() self.account_1.user.favorites.add(private_tweet) self.account_1.user.favorites.add(tweets2015[0]) self.account_1.user.favorites.add(tweets2015[1]) self.account_1.user.favorites.add(tweets2015[2]) self.account_1.user.favorites.add(tweets2016[0]) self.account_1.user.favorites.add(tweets2016[1]) account_2.user.favorites.add(tweets2015[1]) account_2.user.favorites.add(tweets2016[1]) account_3.user.favorites.add(tweets2015[1]) # private user favoriting
def test_args_min_max(self): "Only aggregates scrobble_counts within supplied times." albums = Album.objects.with_scrobble_counts( min_post_time=datetime_from_str('2015-08-12 12:00:00'), max_post_time=datetime_from_str('2015-08-13 12:00:00')) self.assertEqual(len(albums), 1) self.assertEqual(albums[0].scrobble_count, 2)
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'))
def setUp(self): self.user_1 = UserFactory(screen_name='terry') self.user_2 = UserFactory(screen_name='bob') self.user_3 = UserFactory(screen_name='thelma', is_private=True) self.account_1 = AccountFactory(user=self.user_1) account_2 = AccountFactory(user=self.user_2) account_3 = AccountFactory(user=self.user_3) # private # Public tweets in 2015 and 2016: tweets2015 = TweetFactory.create_batch( 3, post_time=datetime_from_str('2015-01-01 12:00:00')) tweets2016 = TweetFactory.create_batch( 2, post_time=datetime_from_str('2016-01-01 12:00:00')) # One private tweet in 2015: private_tweet = TweetFactory( post_time=datetime_from_str('2015-01-01 12:00:00')) private_tweet.user.is_private = True private_tweet.user.save() self.account_1.user.favorites.add(private_tweet) self.account_1.user.favorites.add(tweets2015[0]) self.account_1.user.favorites.add(tweets2015[1]) self.account_1.user.favorites.add(tweets2015[2]) self.account_1.user.favorites.add(tweets2016[0]) self.account_1.user.favorites.add(tweets2016[1]) account_2.user.favorites.add(tweets2015[1]) account_2.user.favorites.add(tweets2016[1]) account_3.user.favorites.add(tweets2015[1]) # private user favoriting
def test_args_min_max(self): "Only aggregates scrobble_counts within supplied times." albums = Album.objects.with_scrobble_counts( min_post_time=datetime_from_str('2015-08-12 12:00:00'), max_post_time=datetime_from_str('2015-08-13 12:00:00') ) self.assertEqual(len(albums), 1) self.assertEqual(albums[0].scrobble_count, 2)
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)
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)
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)
def test_7_days(self): "Has correct scrobble count context when a restricted number of days are viewed." 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("%s?days=7" % reverse('lastfm:album_list')) self.assertEqual(response.context['album_list'][0].scrobble_count, 1)
def test_default_days(self): "Has correct scrobble count context when all days are viewed, the default." 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(reverse('lastfm:track_list')) self.assertEqual(response.context['track_list'][0].scrobble_count, 2)
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'))
def setUp(self): self.artist = ArtistFactory() self.track = TrackFactory(artist=self.artist) # Scrobbled 4 times on different days: scrobble1 = ScrobbleFactory(artist=self.artist, track=self.track, post_time=datetime_from_str('2015-08-11 12:00:00')) scrobble2 = ScrobbleFactory(artist=self.artist, track=self.track, post_time=datetime_from_str('2015-08-12 12:00:00')) scrobble2 = ScrobbleFactory(artist=self.artist, track=self.track, post_time=datetime_from_str('2015-08-13 12:00:00')) scrobble4 = ScrobbleFactory(artist=self.artist, track=self.track, post_time=datetime_from_str('2015-08-14 12:00:00'))
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)
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)
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'))
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)
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)
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)
def setUp(self): self.today = datetime_from_str('2015-11-10 12:00:00') self.tomorrow = self.today + datetime.timedelta(days=1) self.yesterday = self.today - datetime.timedelta(days=1) fl_account = flickrfactories.AccountFactory() self.photo_1 = flickrfactories.PhotoFactory(post_time=self.today, user=fl_account.user) self.photo_2 = flickrfactories.PhotoFactory(post_time=self.tomorrow, user=fl_account.user) self.scrobble_1 = lastfmfactories.ScrobbleFactory(post_time=self.today) self.scrobble_2 = lastfmfactories.ScrobbleFactory( post_time=self.tomorrow) self.bookmark_1 = pinboardfactories.BookmarkFactory( post_time=self.today) self.bookmark_2 = pinboardfactories.BookmarkFactory( post_time=self.tomorrow) tw_account = twitterfactories.AccountFactory() self.tweet_1 = twitterfactories.TweetFactory(post_time=self.today, user=tw_account.user) self.tweet_2 = twitterfactories.TweetFactory(post_time=self.tomorrow, user=tw_account.user) self.favorite_1 = twitterfactories.TweetFactory(post_time=self.today) self.favorite_2 = twitterfactories.TweetFactory( post_time=self.tomorrow) tw_account.user.favorites.add(self.favorite_1)
def setUp(self): account_1 = AccountFactory(username='******') account_2 = AccountFactory(username='******') # Bookmarks in 2015 and 2016 for account_1: BookmarkFactory.create_batch(3, post_time=datetime_from_str('2015-01-01 12:00:00'), account=account_1) BookmarkFactory.create_batch(2, post_time=datetime_from_str('2016-01-01 12:00:00'), account=account_1) # And one for account_2 in 2015: BookmarkFactory(account=account_2, post_time=datetime_from_str('2015-01-01 12:00:00')) # And one private bookmark for account_1 in 2015: BookmarkFactory(account=account_1, is_private=True, post_time=datetime_from_str('2015-01-01 12:00:00'))
def setUp(self): account_1 = AccountFactory(username='******') account_2 = AccountFactory(username='******') # Bookmarks in 2015 and 2016 for account_1: BookmarkFactory.create_batch(3, post_time=datetime_from_str('2015-01-01 12:00:00'), account=account_1) BookmarkFactory.create_batch(2, post_time=datetime_from_str('2016-01-01 12:00:00'), account=account_1) # And one for account_2 in 2015: BookmarkFactory(account=account_2, post_time=datetime_from_str('2015-01-01 12:00:00')) # And one private bookmark for account_1 in 2015: BookmarkFactory(account=account_1, is_private=True, post_time=datetime_from_str('2015-01-01 12:00:00'))
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)
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)
def test_args_max(self): "Only aggregates scrobble_counts before supplied max time." albums = Album.objects.with_scrobble_counts( max_post_time=datetime_from_str('2015-08-13 12:00:00'), ) self.assertEqual(len(albums), 1) self.assertEqual(albums[0].scrobble_count, 3)
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)
def test_args_min(self): "Only aggregates scrobble_counts after supplied min time." tracks = Track.objects.with_scrobble_counts( min_post_time=datetime_from_str('2015-08-12 12:00:00'), ) self.assertEqual(len(tracks), 1) self.assertEqual(tracks[0].scrobble_count, 3)
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)
def test_for_all_accounts(self): "Returns ALL scrobbles from requested date." scrobbles = ditto_lastfm.day_scrobbles( datetime_from_str('2016-10-01 00:00:00')) self.assertEqual(len(scrobbles), 3) self.assertEqual(scrobbles[0], self.scrobble1) self.assertEqual(scrobbles[1], self.scrobble2) self.assertEqual(scrobbles[2], self.scrobble4)
def test_empty_years(self): "It should include years for which there are no bookmarks." # Add a photo in 2018, leaving a gap for 2017: BookmarkFactory(post_time=datetime_from_str('2018-01-01 12:00:00')) bookmarks = ditto_pinboard.annual_bookmark_counts() self.assertEqual(len(bookmarks), 4) self.assertEqual(bookmarks[2]['year'], 2017) self.assertEqual(bookmarks[2]['count'], 0)
def test_for_one_accounts(self): "Only returns scrobbles for one account on requested date." scrobbles = ditto_lastfm.day_scrobbles( account=self.account1, date=datetime_from_str('2016-10-01 00:00:00')) self.assertEqual(len(scrobbles), 2) self.assertEqual(scrobbles[0], self.scrobble1) self.assertEqual(scrobbles[1], self.scrobble2)
def test_empty_years(self): "It should include years for which there are no bookmarks." # Add a photo in 2018, leaving a gap for 2017: BookmarkFactory(post_time=datetime_from_str('2018-01-01 12:00:00')) bookmarks = ditto_pinboard.annual_bookmark_counts() self.assertEqual(len(bookmarks), 4) self.assertEqual(bookmarks[2]['year'], 2017) self.assertEqual(bookmarks[2]['count'], 0)
def test_with_date(self): "Returns when using a date, not a datetime." d = datetime_from_str('2016-10-01 00:00:00').date() scrobbles = ditto_lastfm.day_scrobbles(date=d) self.assertEqual(len(scrobbles), 3) self.assertEqual(scrobbles[0], self.scrobble1) self.assertEqual(scrobbles[1], self.scrobble2) self.assertEqual(scrobbles[2], self.scrobble4)
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'))
def test_empty_years(self): "It should include years for which there are no tweets." # Add a tweet in 2018, leaving a gap for 2017: TweetFactory(post_time=datetime_from_str('2018-01-01 12:00:00'), user=self.user_1) tweets = ditto_twitter.annual_tweet_counts() self.assertEqual(len(tweets), 4) self.assertEqual(tweets[2]['year'], 2017) self.assertEqual(tweets[2]['count'], 0)
def test_empty_years(self): "It should include years for which there are no tweets." # Add a tweet in 2018, leaving a gap for 2017: TweetFactory(post_time=datetime_from_str('2018-01-01 12:00:00'), user=self.user_1) tweets = ditto_twitter.annual_tweet_counts() self.assertEqual(len(tweets), 4) self.assertEqual(tweets[2]['year'], 2017) self.assertEqual(tweets[2]['count'], 0)
def setUp(self): self.user_1 = UserFactory(nsid='1234567890@N01') self.user_2 = UserFactory(nsid='9876543210@N01') AccountFactory(user=self.user_1) AccountFactory(user=self.user_2) # Photos taken in 2015 and 2016 for user 1: PhotoFactory.create_batch(3, taken_time=datetime_from_str('2015-01-01 12:00:00'), user=self.user_1) PhotoFactory.create_batch(2, taken_time=datetime_from_str('2016-01-01 12:00:00'), user=self.user_1) # And one for user_2 taken in 2015: PhotoFactory(user=self.user_2, taken_time=datetime_from_str('2015-01-01 12:00:00')) # And one private photo for user_1 taken in 2015: PhotoFactory(user=self.user_1, is_private=True, taken_time=datetime_from_str('2015-01-01 12:00:00'))
def test_empty_years(self): "It should include years for which there are no photos." # Add a photo in 2018, leaving a gap for 2017: PhotoFactory(taken_time=datetime_from_str('2018-01-01 12:00:00'), user=self.user_1) photos = ditto_flickr.annual_photo_counts(count_by='taken_time') self.assertEqual(len(photos), 4) self.assertEqual(photos[2]['year'], 2017) self.assertEqual(photos[2]['count'], 0)
def test_empty_years(self): "It should include years for which there are no photos." # Add a photo in 2018, leaving a gap for 2017: PhotoFactory(taken_time=datetime_from_str('2018-01-01 12:00:00'), user=self.user_1) photos = ditto_flickr.annual_photo_counts(count_by='taken_time') self.assertEqual(len(photos), 4) self.assertEqual(photos[2]['year'], 2017) self.assertEqual(photos[2]['count'], 0)
def test_empty_years(self): "It should include years for which there are no favorited tweets." # Add a favorite tweet in 2018, leaving a gap for 2017: tweet2018 = TweetFactory( post_time=datetime_from_str('2018-01-01 12:00:00')) self.account_1.user.favorites.add(tweet2018) tweets = ditto_twitter.annual_favorite_counts() self.assertEqual(len(tweets), 4) self.assertEqual(tweets[2]['year'], 2017) self.assertEqual(tweets[2]['count'], 0)
def test_empty_years(self): "It should include years for which there are no favorited tweets." # Add a favorite tweet in 2018, leaving a gap for 2017: tweet2018 = TweetFactory( post_time=datetime_from_str('2018-01-01 12:00:00')) self.account_1.user.favorites.add(tweet2018) tweets = ditto_twitter.annual_favorite_counts() self.assertEqual(len(tweets), 4) self.assertEqual(tweets[2]['year'], 2017) self.assertEqual(tweets[2]['count'], 0)
def setUp(self): self.user_1 = UserFactory(nsid='1234567890@N01') self.user_2 = UserFactory(nsid='9876543210@N01') AccountFactory(user=self.user_1) AccountFactory(user=self.user_2) # Photos taken in 2015 and 2016 for user 1: PhotoFactory.create_batch( 3, taken_time=datetime_from_str('2015-01-01 12:00:00'), user=self.user_1) PhotoFactory.create_batch( 2, taken_time=datetime_from_str('2016-01-01 12:00:00'), user=self.user_1) # And one for user_2 taken in 2015: PhotoFactory(user=self.user_2, taken_time=datetime_from_str('2015-01-01 12:00:00')) # And one private photo for user_1 taken in 2015: PhotoFactory(user=self.user_1, is_private=True, taken_time=datetime_from_str('2015-01-01 12:00:00'))
def setUp(self): self.artist = ArtistFactory() self.track = TrackFactory(artist=self.artist) # Scrobbled 4 times on different days: scrobble1 = ScrobbleFactory( artist=self.artist, track=self.track, post_time=datetime_from_str('2015-08-11 12:00:00')) scrobble2 = ScrobbleFactory( artist=self.artist, track=self.track, post_time=datetime_from_str('2015-08-12 12:00:00')) scrobble2 = ScrobbleFactory( artist=self.artist, track=self.track, post_time=datetime_from_str('2015-08-13 12:00:00')) scrobble4 = ScrobbleFactory( artist=self.artist, track=self.track, post_time=datetime_from_str('2015-08-14 12:00:00'))
def setUp(self): self.user_1 = UserFactory(screen_name='terry') self.user_2 = UserFactory(screen_name='bob') self.user_3 = UserFactory(screen_name='thelma', is_private=True) account_1 = AccountFactory(user=self.user_1) account_2 = AccountFactory(user=self.user_2) account_3 = AccountFactory(user=self.user_3) # Tweets in 2015 and 2016 for user 1: TweetFactory.create_batch( 3, post_time=datetime_from_str('2015-01-01 12:00:00'), user=self.user_1) TweetFactory.create_batch( 2, post_time=datetime_from_str('2016-01-01 12:00:00'), user=self.user_1) # And one for self.user_2 in 2015: TweetFactory(user=self.user_2, post_time=datetime_from_str('2015-01-01 12:00:00')) # And one tweet in 2015 for the private user 3. tw = TweetFactory(user=self.user_3, is_private=True, post_time=datetime_from_str('2015-01-01 12:00:00'))