Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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
            )
Beispiel #7
0
    def test_prevent_multiple_replies(self):
        t = tweet(save=True)
        eq_(t.replies.count(), 0)

        tweet(reply_to=t, save=True)
        eq_(t.replies.count(), 1)

        response = self.client.post(reverse('customercare.twitter_post'), {
            'reply_to': 1,
            'content': '@foobar try Aurora! #fxhelp'
        })

        eq_(response.status_code, 400)
        eq_(t.replies.count(), 1)
Beispiel #8
0
    def test_prevent_multiple_replies(self):
        t = tweet(save=True)
        eq_(t.replies.count(), 0)

        tweet(reply_to=t, save=True)
        eq_(t.replies.count(), 1)

        response = self.client.post(
            reverse('customercare.twitter_post'),
            {'reply_to': 1,
             'content': '@foobar try Aurora! #fxhelp'})

        eq_(response.status_code, 400)
        eq_(t.replies.count(), 1)
Beispiel #9
0
    def setUp(self):
        """Set up FilterTests

        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()
Beispiel #10
0
    def setUp(self):
        """Set up FilterTests

        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()
Beispiel #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)
Beispiel #12
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)
Beispiel #13
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)
Beispiel #14
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)

        self.client.login(username=user(save=True), password='******')
Beispiel #15
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)

        self.client.login(username=user(save=True), password='******')
Beispiel #16
0
    def test_caching(self):
        """Refiltering list after replying shows replied-to tweet"""
        # 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')
Beispiel #17
0
    def test_caching(self):
        """Refiltering list after replying shows replied-to tweet"""
        # 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')
Beispiel #18
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
     )
Beispiel #19
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)
Beispiel #20
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)