Esempio n. 1
0
    def test_given_one_short_sentence_without_header_when_split_tweets_then_one_tweet_returned(
            self):

        sentence = "this is a shot sentence"
        sentences = [sentence]
        twitter = Twitter()

        result = twitter._split_tweets(sentences, None)

        self.assertEqual(sentences, result)
Esempio n. 2
0
    def test_given_one_short_sentence_with_header_when_split_tweets_then_sentence_with_header_returned(
            self):

        sentence = "this is a shot sentence"
        header = "this is a header"
        sentences = [sentence]
        twitter = Twitter()

        result = twitter._split_tweets(sentences, header)

        self.assertEqual([header + " (1/1):\n\n" + sentence], result)
Esempio n. 3
0
    def test_given_sentences_with_length_above_280_with_header_when_split_tweets_then_two_tweet_returned(
            self):
        sentence = "this is a shot sentence"
        header = "this is a header"
        sentences = 20 * [sentence]
        twitter = Twitter()

        result = twitter._split_tweets(sentences, header)

        self.assertEqual(2, len(result))
        self.assertTrue(result[0].startswith(header + " (1/2):\n\n"))
        self.assertTrue(result[1].startswith(header + " (2/2):\n\n"))
Esempio n. 4
0
    def test_given_sentences_with_length_below_280_with_header_when_split_tweets_then_one_tweet_returned(
            self):
        sentence1 = "this is a shot sentence"
        sentence2 = "this is another sentence"
        header = "this is a header"
        sentences = [sentence1, sentence2]
        twitter = Twitter()

        result = twitter._split_tweets(sentences, header)

        self.assertEqual(
            [header + " (1/1):\n\n" + sentence1 + "\n" + sentence2], result)
Esempio n. 5
0
    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)