def test_when_publish_sentences_in_tweets_then_split_and_publish(self): twitter = Twitter() twitter._split_tweets = MagicMock() twitter.publish_tweets = MagicMock() sentences = MagicMock() header = MagicMock() last_tweet = MagicMock() result = twitter.publish_sentences_in_tweets(sentences, header, last_tweet) self.assertEqual(twitter.publish_tweets.return_value, result) twitter._split_tweets.assert_called_once_with(sentences, header) twitter.publish_tweets.assert_called_once_with( twitter._split_tweets.return_value, last_tweet=last_tweet)
def test_when_publish_tweets_then_split_and_publish(self): twitter = Twitter() tweet1_id = 123 tweet2_id = 456 previous_id = 789 tweet1 = "test1" tweet2 = "test2" twitter.publish_tweet = MagicMock(side_effect=[tweet1_id, tweet2_id]) tweets = [tweet1, tweet2] last_tweet_id = twitter.publish_tweets(tweets, previous_id) self.assertEqual(tweet2_id, last_tweet_id) twitter.publish_tweet.assert_has_calls( [call(tweet1, previous_id), call(tweet2, tweet1_id)])