示例#1
0
    def test_hide_tweets_with_replies(self):
        """Hiding tweets with replies is not allowed."""
        tw = tweet(save=True)
        reply_tw = tweet(save=True)
        reply_tw.reply_to_id = tw.tweet_id
        reply_tw.save()

        r = self.client.post(
            reverse('customercare.hide_tweet', locale='en-US'),
            {'id': tw.tweet_id})
        eq_(r.status_code, 400)
示例#2
0
    def test_hide_tweets_with_replies(self):
        """Hiding tweets with replies is not allowed."""
        tw = tweet(save=True)
        reply_tw = tweet(save=True)
        reply_tw.reply_to_id = tw.tweet_id
        reply_tw.save()

        r = self.client.post(
            reverse('customercare.hide_tweet', locale='en-US'),
            {'id': tw.tweet_id})
        eq_(r.status_code, 400)
示例#3
0
    def setUp(self):
        # 4 'en' and 2 'r'
        for i in range(0, 6):
            if i >= 4:
                locale = 'ro'
            else:
                locale = 'en'

            tweet(locale=locale,
                  created=datetime.now() - timedelta(hours=i),
                  save=True)
示例#4
0
    def test_count_replies(self):
        """Test filtering when counting tweets"""
        tweet(save=True)
        id = Tweet.latest().tweet_id

        reply(reply_to_tweet_id=id, created=datetime.now(), save=True)
        reply(reply_to_tweet_id=id, created=datetime.now(), save=True)
        reply(created=datetime.now() - timedelta(days=1, minutes=1), save=True)

        yesterday = datetime.now() - timedelta(days=1)
        count_recent_answered = _count_answered_tweets(since=yesterday)
        eq_(count_recent_answered, 1)
示例#5
0
    def test_count_replies(self):
        """Test filtering when counting tweets"""
        tweet(save=True)
        id = Tweet.latest().tweet_id

        reply(reply_to_tweet_id=id, created=datetime.now(), save=True)
        reply(reply_to_tweet_id=id, created=datetime.now(), save=True)
        reply(created=datetime.now() - timedelta(days=1, minutes=1), save=True)

        yesterday = datetime.now() - timedelta(days=1)
        count_recent_answered = _count_answered_tweets(since=yesterday)
        eq_(count_recent_answered, 1)
示例#6
0
    def setUp(self):
        # 4 'en' and 2 'r'
        for i in range(0, 6):
            if i >= 4:
                locale = 'ro'
            else:
                locale = 'en'

            tweet(
                locale=locale,
                created=datetime.now() - timedelta(hours=i),
                save=True
            )
示例#7
0
    def setUp(self):
        """Make a tweet, an answer to it, an unanswered tweet, and a hidden
        one."""
        super(FilterTests, self).setUp()

        tweet(text='YO_UNANSWERED').save()
        cry_for_help = tweet(text='YO_HELP_ME', save=True)
        tweet(text='YO_REPLY', reply_to=cry_for_help).save()
        tweet(text='YO_HIDDEN', hidden=True).save()
示例#8
0
    def setUp(self):
        """Make a tweet, an answer to it, an unanswered tweet, and a hidden
        one."""
        super(FilterTests, self).setUp()

        tweet(text='YO_UNANSWERED').save()
        cry_for_help = tweet(text='YO_HELP_ME', save=True)
        tweet(text='YO_REPLY', reply_to=cry_for_help).save()
        tweet(text='YO_HIDDEN', hidden=True).save()
示例#9
0
 def setUp(self):
     tweet(tweet_id=1,
           locale='en',
           created='2010-09-23 13:50:00',
           save=True)
     tweet(tweet_id=2,
           locale='en',
           created='2010-09-23 13:53:00',
           save=True)
     tweet(tweet_id=3,
           created='2010-09-23 13:57:00',
           locale='en',
           save=True)
示例#10
0
    def setUp(self):
        for i in range(0, 11):
            tweet(save=True)

        now = datetime.now()

        # Create a tweet older than CC_TWEETS_DAYS days
        older = now - timedelta(days=settings.CC_TWEETS_DAYS)
        tweet(save=True, created=older)

        # Create a tweet on the last CC_TWEETS_DAYS day
        last = now - timedelta(days=settings.CC_TWEETS_DAYS - 1)
        tweet(save=True, created=last)
示例#11
0
    def setUp(self):
        for i in range(0, 11):
            tweet(save=True)

        now = datetime.now()

        # Create a tweet older than CC_TWEETS_DAYS days
        older = now - timedelta(days=settings.CC_TWEETS_DAYS)
        tweet(save=True, created=older)

        # Create a tweet on the last CC_TWEETS_DAYS day
        last = now - timedelta(days=settings.CC_TWEETS_DAYS - 1)
        tweet(save=True, created=last)
示例#12
0
    def test_caching(self):
        """Ensure refiltering the list after replying shows the replied-to tweet as such."""
        # We need at least one existing answer to get the list of answered
        # tweets to cache:
        question = tweet(save=True)
        tweet(reply_to=question).save()

        # Make a sad, sad, unanswered tweet:
        cry_for_help = tweet(text='YO_UNANSWERED', save=True)

        # Cache the list of answered tweets:
        self._tweet_list('answered')

        # Reply to the lonely tweet:
        tweet(text='YO_REPLY', reply_to=cry_for_help).save()

        # And make sure we can immediately see that we replied:
        assert 'YO_UNANSWERED' in self._tweet_list('answered')
示例#13
0
    def test_caching(self):
        """Ensure refiltering the list after replying shows the replied-to tweet as such."""
        # We need at least one existing answer to get the list of answered
        # tweets to cache:
        question = tweet(save=True)
        tweet(reply_to=question).save()

        # Make a sad, sad, unanswered tweet:
        cry_for_help = tweet(text='YO_UNANSWERED', save=True)

        # Cache the list of answered tweets:
        self._tweet_list('answered')

        # Reply to the lonely tweet:
        tweet(text='YO_REPLY', reply_to=cry_for_help).save()

        # And make sure we can immediately see that we replied:
        assert 'YO_UNANSWERED' in self._tweet_list('answered')
示例#14
0
 def setUp(self):
     tweet(
         tweet_id=1,
         locale='en',
         created='2010-09-23 13:50:00',
         save=True
     )
     tweet(
         tweet_id=2,
         locale='en',
         created='2010-09-23 13:53:00',
         save=True
     )
     tweet(
         tweet_id=3,
         created='2010-09-23 13:57:00',
         locale='en',
         save=True
     )
示例#15
0
 def test_latest(self):
     """Test the latest() class method when there is a latest tweet."""
     NUM = 2
     for x in xrange(NUM):
         last = tweet(save=True)
     eq_(last.tweet_id, Tweet.latest().tweet_id)