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())
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()
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
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)
def test_appraise_when_no_twitter_data(self): content = factory.ContentFactory() self.assertEqual(content.appraise(), 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())
def test_maker_max_length(self): maker = 'a' * 51 with self.assertRaises(DataError): factory.ContentFactory(maker=maker)
def test_screen_name_max_length(self): name = 'a' * 51 with self.assertRaises(DataError): factory.ContentFactory(screen_name=name)
def test_screen_name_unique(self): factory.ContentFactory(screen_name='sample') with self.assertRaises(IntegrityError): factory.ContentFactory(screen_name='sample')
def test_name_unique(self): factory.ContentFactory(name='movie A') with self.assertRaises(IntegrityError): factory.ContentFactory(name='movie A')
def setUp(self): self.screen_name = 'sample_screen_name' self.content = factory.ContentFactory(screen_name=self.screen_name)