示例#1
0
    def test_has_tweets_no_twitter_and_only_twitter_user(self):
        content = factory.ContentFactory()

        self.assertFalse(content.has_tweets())

        factory.TwitterUserFactory(content=content)

        self.assertTrue(content.has_tweets())
示例#2
0
    def test_get_and_store_twitter_data_without_screen_name(
            self, mock_get_base):
        mock_get_base.side_effect = response_data_mock

        content = factory.ContentFactory(screen_name=None)
        TwitterApi().get_and_store_twitter_data(content)

        mock_get_base.assert_not_called()
示例#3
0
 def create_content_twitter_tweet_tweetcount(category, retweet=10):
     content = factory.ContentFactory(category=category)
     twitter_user = factory.TwitterUserFactory(content=content)
     for num in range(50):
         tweet = factory.TweetFactory(twitter_user=twitter_user)
         factory.TweetCountFactory(tweet=tweet,
                                   retweet_count=retweet,
                                   favorite_count=20)
     twitter_user.loads_tweet()
     return content
示例#4
0
    def test_appraise(self):
        content = factory.ContentFactory()
        twitter_user = factory.TwitterUserFactory(content=content)
        for num in range(50):
            tweet = factory.TweetFactory(tweet_id=str(num),
                                         twitter_user=twitter_user)
            factory.TweetCountFactory(tweet=tweet,
                                      retweet_count=10,
                                      favorite_count=20)
        twitter_user.loads_tweet()

        self.assertEqual(content.appraise(), 0.40)
示例#5
0
    def test_appraise_when_no_twitter_data(self):
        content = factory.ContentFactory()

        self.assertEqual(content.appraise(), 0)
示例#6
0
    def test_has_tweets(self):
        content = factory.ContentFactory()
        twitter_user = factory.TwitterUserFactory(content=content)
        factory.TweetFactory(twitter_user=twitter_user, tweet_id='1')

        self.assertTrue(content.has_tweets())
示例#7
0
 def test_maker_max_length(self):
     maker = 'a' * 51
     with self.assertRaises(DataError):
         factory.ContentFactory(maker=maker)
示例#8
0
 def test_screen_name_max_length(self):
     name = 'a' * 51
     with self.assertRaises(DataError):
         factory.ContentFactory(screen_name=name)
示例#9
0
 def test_screen_name_unique(self):
     factory.ContentFactory(screen_name='sample')
     with self.assertRaises(IntegrityError):
         factory.ContentFactory(screen_name='sample')
示例#10
0
 def test_name_unique(self):
     factory.ContentFactory(name='movie A')
     with self.assertRaises(IntegrityError):
         factory.ContentFactory(name='movie A')
示例#11
0
 def setUp(self):
     self.screen_name = 'sample_screen_name'
     self.content = factory.ContentFactory(screen_name=self.screen_name)