def test_get_tweets(self, mock_oauthhandler):

        mock_tweets = [Mock(text="@Tweet")]

        with patch.object(
                API, 'user_timeline', return_value=mock_tweets) as mock_api:

            tweets = get_tweets(10)
            assert not mock_api.called
            self.assertEquals([], tweets)
    def test_get_tweets(self, mock_oauthhandler):

        mock_tweets = [Mock(text="@Tweet")]

        with patch.object(
                API, 'user_timeline', return_value=mock_tweets) as mock_api:

            tweets = get_tweets(10)

            mock_api.assert_called_once_with('pythonglasgow', count=10)

            formatted_tweet = ('@<a href="http://twitter.com/Tweet"  '
                               'title="#Tweet on Twitter">Tweet</a>')

            self.assertEquals([(mock_tweets[0], formatted_tweet), ], tweets)
    def test_get_tweets_error(self, mock_oauthhandler):

        with patch.object(
                API, 'user_timeline', side_effect=TweepError("")):

            get_tweets(10)