import twitter_v2_facade as t2f """ 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 (): 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' } } includes = tweet_api_resp.get('includes') tweet_data = tweet_api_resp.get('data')[0] tweet = t2f.tweet_model (includes, tweet_data, 'TEST', my_url_for = mock_url_for) assert(tweet['id'] == 12345) assert(tweet['text'] == 'A tweet!') assert(tweet['author_id'] == 456) assert(tweet['display_name'] == 'User 456')