def test_favorites_manager(self): "Should contain recent tweets favorited by any account." accounts = AccountFactory.create_batch(2) tweets = TweetFactory.create_batch(5) accounts[0].user.favorites.add(tweets[2]) accounts[0].user.favorites.add(tweets[4]) accounts[1].user.favorites.add(tweets[2]) favorites = Tweet.favorite_objects.all() self.assertEqual(len(favorites), 2) self.assertEqual(favorites[0].pk, tweets[4].pk) self.assertEqual(favorites[1].pk, tweets[2].pk)
def test_favorites_manager(self): "Should contain recent tweets favorited by any account." accounts = AccountFactory.create_batch(2) tweets = TweetFactory.create_batch(5) accounts[0].user.favorites.add(tweets[2]) accounts[0].user.favorites.add(tweets[4]) accounts[1].user.favorites.add(tweets[2]) favorites = Tweet.favorite_objects.all() self.assertEqual(len(favorites), 2) self.assertEqual(favorites[0].pk, tweets[4].pk) self.assertEqual(favorites[1].pk, tweets[2].pk)
def test_public_favorites_tweets_manager(self): "Should contain recent PUBLIC tweets favorited the Accounts" accounts = AccountFactory.create_batch(2) public_user = UserFactory(is_private=False) private_user = UserFactory(is_private=True) public_tweet = TweetFactory(user=public_user) private_tweet = TweetFactory(user=private_user) accounts[0].user.favorites.add(private_tweet) accounts[0].user.favorites.add(public_tweet) accounts[1].user.favorites.add(private_tweet) favorites = Tweet.public_favorite_objects.all() self.assertEqual(len(favorites), 1) self.assertEqual(favorites[0].pk, public_tweet.pk)
def test_public_favorites_tweets_manager(self): "Should contain recent PUBLIC tweets favorited the Accounts" accounts = AccountFactory.create_batch(2) public_user = UserFactory(is_private=False) private_user = UserFactory(is_private=True) public_tweet = TweetFactory(user=public_user) private_tweet = TweetFactory(user=private_user) accounts[0].user.favorites.add(private_tweet) accounts[0].user.favorites.add(public_tweet) accounts[1].user.favorites.add(private_tweet) favorites = Tweet.public_favorite_objects.all() self.assertEqual(len(favorites), 1) self.assertEqual(favorites[0].pk, public_tweet.pk)