def test_twitter_search_throws_error(): twitter = Twitter() api = mock.create_autospec(API) api.search.side_effect = TweepError('Something Bad Happened', mock.Mock(status_code=400)) twitter._api = api with pytest.raises(TwitterError): twitter.search('Fred')
def test_twitter_search_throws_error(): twitter = Twitter() api = mock.create_autospec(API) api.search.side_effect = TweepError('Something Bad Happened', mock.Mock(status_code=400)) twitter._api = api with pytest.raises(TwitterError): twitter.search('Fred')
def test_twitter_search_happy_path(): twitter = Twitter() api = mock.create_autospec(API) api.search.return_value = [mock.Mock(user=mock.Mock(screen_name='Fred'), text='Some Text', id_str='1')] twitter._api = api tweets = twitter.search('Fred') assert api.search.call_args == mock.call('Fred') assert tweets == [{'user': '******', 'text': 'Some Text', 'url': 'https://twitter.com/Fred/status/1'}]
def test_twitter_search_happy_path(): twitter = Twitter() api = mock.create_autospec(API) api.search.return_value = [ mock.Mock(user=mock.Mock(screen_name='Fred'), text='Some Text', id_str='1') ] twitter._api = api tweets = twitter.search('Fred') assert api.search.call_args == mock.call('Fred') assert tweets == [{ 'user': '******', 'text': 'Some Text', 'url': 'https://twitter.com/Fred/status/1' }]