import responses

from twitter_v2.api import ApiV2TweetSource

@responses.activate
def test_create_tweet ():
    
    fake_res = {
        'id': 1234,
        'text': 'Test Text'
    }
    
    responses.add(responses.POST, 'https://api.twitter.com/2/tweets',
                  json=fake_res, status=200)
    
    tweet_source = ApiV2TweetSource('FAKE TOKEN')
    
    res = tweet_source.create_tweet('Test Text')
    
    assert len(responses.calls) == 1
    
    assert(res == fake_res)

@responses.activate
def test_get_timeline ():
    
    fake_res = {
        'meta': 1234,
        'text': 'Test Text'
    }
    
    responses.add(responses.GET, 'https://api.twitter.com/2/timeline/test',
                  json=fake_res, status=200)
    
    tweet_source = ApiV2TweetSource('FAKE TOKEN')
    
    res = tweet_source.get_timeline('timeline/test', pagination_token='1234')
    
    assert len(responses.calls) == 1
    
    req = responses.calls[0].request
    assert req.params.get('pagination_token') == '1234'
    
    assert(res == fake_res)