Exemple #1
0
    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)
Exemple #2
0
    def test_favorite_list_privacy_tweets(self):
        "Only public Tweets should appear."
        private_user = factories.UserFactory(is_private=True)
        public_users = factories.UserFactory.create_batch(2, is_private=False)

        favoriting_account = factories.AccountFactory(user=public_users[0])
        private_tweet = factories.TweetFactory(user=private_user)
        public_tweet = factories.TweetFactory(user=public_users[1])

        favoriting_account.user.favorites.add(private_tweet)
        favoriting_account.user.favorites.add(public_tweet)

        response = self.client.get(reverse('twitter:favorite_list'))

        tweets = response.context['tweet_list']
        self.assertEqual(len(tweets), 1)
        self.assertEqual(tweets[0].pk, public_tweet.pk)
Exemple #3
0
    def test_home_privacy_twitter_recent(self):
        "Overall home page does not display private Tweets"
        private_user = twitterfactories.UserFactory(is_private=True)
        public_user = twitterfactories.UserFactory(is_private=False)

        private_account = twitterfactories.AccountFactory(user=private_user)
        public_account = twitterfactories.AccountFactory(user=public_user)

        public_tweet_1 = twitterfactories.TweetFactory(user=public_user)
        private_tweet = twitterfactories.TweetFactory(user=private_user)
        public_tweet_2 = twitterfactories.TweetFactory(user=public_user)

        response = self.client.get(reverse('ditto:home'))

        tweets = response.context['object_list']
        self.assertEqual(len(tweets), 2)
        self.assertEqual(tweets[0].pk, public_tweet_2.pk)
        self.assertEqual(tweets[1].pk, public_tweet_1.pk)
Exemple #4
0
    def test_home_privacy(self):
        "Only public Tweets should appear."
        private_user = factories.UserFactory(is_private=True)
        public_user = factories.UserFactory(is_private=False)

        # We only display tweets from Accounts, so add some.
        private_account = factories.AccountFactory(user=private_user)
        public_account = factories.AccountFactory(user=public_user)

        public_tweet_1 = factories.TweetFactory(user=public_user)
        private_tweet = factories.TweetFactory(user=private_user)
        public_tweet_2 = factories.TweetFactory(user=public_user)

        response = self.client.get(reverse('twitter:home'))
        tweets = response.context['tweet_list']
        self.assertEqual(len(tweets), 2)
        self.assertEqual(tweets[0].pk, public_tweet_2.pk)
        self.assertEqual(tweets[1].pk, public_tweet_1.pk)
Exemple #5
0
    def test_account_favorite_list_privacy_tweets(self):
        "It does not show private Tweets"
        private_user = factories.UserFactory(is_private=True)
        public_users = factories.UserFactory.create_batch(2, is_private=False)

        favoriting_account = factories.AccountFactory(user=public_users[0])
        private_tweet = factories.TweetFactory(user=private_user)
        public_tweet = factories.TweetFactory(user=public_users[1])

        favoriting_account.user.favorites.add(private_tweet)
        favoriting_account.user.favorites.add(public_tweet)

        response = self.client.get(
            reverse(
                'twitter:account_favorite_list',
                kwargs={'screen_name': favoriting_account.user.screen_name}))

        tweets = response.context['tweet_list']
        self.assertEqual(len(tweets), 1)
        self.assertEqual(tweets[0].pk, public_tweet.pk)
Exemple #6
0
    def test_favorite_list_privacy_accounts(self):
        "Only Tweets favorited by Accounts with public Users should appear."
        user = factories.UserFactory(is_private=True)
        account = factories.AccountFactory(user=user)
        tweet = factories.TweetFactory()
        account.user.favorites.add(tweet)
        # Check it is there:
        self.assertEqual(account.user.favorites.count(), 1)

        response = self.client.get(reverse('twitter:favorite_list'))
        tweets = response.context['tweet_list']
        # Check it doesn't appear on the page:
        self.assertEqual(len(tweets), 0)
Exemple #7
0
 def test_account_favorite_list_privacy_account(self):
     "It does not show favorites if the account's user is private"
     user = factories.UserFactory(is_private=True)
     account = factories.AccountFactory(user=user)
     tweet = factories.TweetFactory()
     account.user.favorites.add(tweet)
     # Check it is there:
     self.assertEqual(account.user.favorites.count(), 1)
     response = self.client.get(
         reverse('twitter:account_favorite_list',
                 kwargs={'screen_name': account.user.screen_name}))
     tweets = response.context['tweet_list']
     # Check it doesn't appear on the page:
     self.assertEqual(len(tweets), 0)