Esempio n. 1
0
 def test_timeline_is_successful(self, mock_token, mock_twython):
     mock_token.return_value = 'access_token'
     mock_instance = Mock(spec=twython.Twython)()
     mock_instance.get_user_timeline.return_value = [1] * 10
     mock_twython.return_value = mock_instance
     timeline = twitter.get_timeline('us_ignite')
     mock_token.assert_called_once()
     mock_twython.assert_called_once_with(
         settings.TWITTER_API_KEY, access_token='access_token')
     eq_(timeline, [1, 1, 1, 1, 1])
Esempio n. 2
0
def render_twitter(parsed_url):
    path_bits = parsed_url.path.split('/')
    try:
        username = path_bits.pop(1)
    except IndexError:
        return u''
    tweet_list = twitter.get_timeline(username)
    context = {
        'parsed_url': parsed_url,
        'username': username,
        'tweet_list': tweet_list,
    }
    return render_to_string('apps/includes/twitter.html', context)
Esempio n. 3
0
 def test_missing_settings_bailout_timeline(self, mock_twython):
     timeline = twitter.get_timeline('us_ignite')
     eq_(timeline, [])