import dacite
import twitter_v2.types as tv2_types
import twitter_v2_facade.view_model as vm


"""

The big item to test here is tweet_model() which converts a Tweet into a UI view and action links.

"""

def mock_url_for (route, *args, **kwargs):
    return 'URL:' + route


def test_tweet_model ():
    """
    This should be testing against twitter_v2 or tweet_source instead of an HTTP response. 
    Very old code.
    """
    tweet_api_resp = {
        'data': [{
            'id': "12345",
            'text': 'A tweet!',
            'created_at': 'a time',
            'author_id': "456",
            
            'conversation_id': "12345"
            
        }
        
        ],
        'includes': {
            'tweets': [],
            'users': [{
                'id': "456",
                'username': 'user456',
                'name': 'User 456',
                'verified': False,
                'profile_image_url': 'pfp_url'
            }],
            'media': []
        },
        'meta': {
            'result_count': 1,
            # 'next_token': 'AAA'
        }
    }
    
    
    tweet_response = dacite.from_dict(data_class=tv2_types.TweetSearchResponse, data=tweet_api_resp)
    
    tweet = vm.tweet_model_dc_vm (tweet_response.includes, tweet_response.data[0], 'TEST', my_url_for = mock_url_for, my_g={})
    
    assert(tweet.id == "12345")
    assert(tweet.text == 'A tweet!')
    
    assert(tweet.author_id == "456")
    assert(tweet.display_name == 'User 456')
    