Fixed tests & added test generator in case tweets are deleted
This commit is contained in:
parent
c2da462414
commit
602cd8cb51
89
test_vx.py
89
test_vx.py
@ -6,28 +6,31 @@ import msgs
|
||||
from flask.testing import FlaskClient
|
||||
client = FlaskClient(twitfix.app)
|
||||
|
||||
twitterAccountName='X' # the fact that I have to do this in the rare chance that they change their username back is stupid
|
||||
# autogenerated from testgen.py
|
||||
testTextTweet="https://twitter.com/jack/status/20"
|
||||
testVideoTweet="https://twitter.com/pdxdylan/status/1540398733669666818"
|
||||
testMediaTweet="https://twitter.com/pdxdylan/status/1534672932106035200"
|
||||
testMultiMediaTweet="https://twitter.com/pdxdylan/status/1532006436703715331"
|
||||
testQRTTweet="https://twitter.com/pdxdylan/status/1611477137319514129"
|
||||
testQrtCeptionTweet="https://twitter.com/CatherineShu/status/585253766271672320"
|
||||
testQrtVideoTweet="https://twitter.com/pdxdylan/status/1674561759422578690"
|
||||
testNSFWTweet="https://twitter.com/kuyacoy/status/1581185279376838657"
|
||||
|
||||
testTextTweet_compare={'tweet': 'https://twitter.com/jack/status/20', 'url': '', 'description': 'just setting up my twttr', 'thumbnail': '', 'type': 'Text', 'images': ['', '', '', '', ''], 'time': '2006-03-21T20:50:14.000Z', 'qrtURL': None, 'nsfw': False, 'size': {}, 'isGif': False}
|
||||
testVideoTweet_compare={'tweet': 'https://twitter.com/pdxdylan/status/1540398733669666818', 'url': 'https://video.twimg.com/ext_tw_video/1540396699037929472/pu/vid/762x528/YxbXbT3X7vq4LWfC.mp4?tag=12', 'description': 'TikTok embeds on Discord/Telegram bait you with a fake play button, but to see the actual video you have to go to their website.\nAs a request from a friend, I made it so that if you add "vx" before "tiktok" on any link, it fixes that. https://t.co/QYpiVXUIrW', 'thumbnail': 'https://pbs.twimg.com/ext_tw_video_thumb/1540396699037929472/pu/img/l187Z6B9AHHxUKPV.jpg', 'type': 'Video', 'images': ['', '', '', '', ''], 'time': '2022-06-24T18:17:31.000Z', 'qrtURL': None, 'nsfw': False, 'size': {'height': 528, 'width': 762, 'focus_rects': []}, 'isGif': False}
|
||||
testMediaTweet_compare={'tweet': 'https://twitter.com/pdxdylan/status/1534672932106035200', 'url': '', 'description': 'oh. https://t.co/HgLAbiXw2E', 'thumbnail': 'https://pbs.twimg.com/media/FUxAt5LWUAMol0N.png', 'type': 'Image', 'images': ['https://pbs.twimg.com/media/FUxAt5LWUAMol0N.png', '', '', '', '1'], 'time': '2022-06-08T23:05:14.000Z', 'qrtURL': None, 'nsfw': False, 'size': {}, 'isGif': False}
|
||||
testMultiMediaTweet_compare={'tweet': 'https://twitter.com/pdxdylan/status/1532006436703715331', 'url': '', 'description': 'Released #Retro64 1.0.9. Besides a lot of internal bug-fixes, this adds quicksand blocks, fixes the rendering for the castle stairs block, and adds a new model, Sonic! \nhttps://github.com/Retro64Mod/Retro64Mod/releases/tag/1.18.2-1.0.9 https://t.co/CWZaw4hzyg', 'thumbnail': 'https://pbs.twimg.com/media/FULF9oxXwAMDI-C.png', 'type': 'Image', 'images': ['https://pbs.twimg.com/media/FULF9oxXwAMDI-C.png', 'https://pbs.twimg.com/media/FULGaHkWYAIBV5U.png', 'https://pbs.twimg.com/media/FULGiZnWQAMBRWl.png', '', '3'], 'time': '2022-06-01T14:29:32.000Z', 'qrtURL': None, 'nsfw': False, 'size': {}, 'isGif': False}
|
||||
testQRTTweet_compare={'tweet': 'https://twitter.com/pdxdylan/status/1611477137319514129', 'url': '', 'description': "vxTwitter has gotten a *ton* of usage recently, so I'd appreciate a donation to keep things running!\n", 'thumbnail': '', 'type': 'Text', 'images': ['', '', '', '', ''], 'time': '2023-01-06T21:37:43.000Z', 'qrtURL': 'https://twitter.com/pdxdylan/status/1518309187515781125', 'nsfw': False, 'size': {}, 'isGif': False}
|
||||
testQrtCeptionTweet_compare={'tweet': 'https://twitter.com/CatherineShu/status/585253766271672320', 'url': '', 'description': 'Testing retweetception ', 'thumbnail': '', 'type': 'Text', 'images': ['', '', '', '', ''], 'time': '2015-04-07T01:32:26.000Z', 'qrtURL': 'https://twitter.com/EliLanger/status/585253161260216320', 'nsfw': False, 'size': {}, 'isGif': False}
|
||||
testQrtVideoTweet_compare={'tweet': 'https://twitter.com/pdxdylan/status/1674561759422578690', 'url': '', 'description': 'good', 'thumbnail': '', 'type': 'Text', 'images': ['', '', '', '', ''], 'time': '2023-06-29T23:33:29.000Z', 'qrtURL': 'https://twitter.com/TeaboyAllStars/status/1674197531301904388', 'nsfw': False, 'size': {}, 'isGif': False}
|
||||
testNSFWTweet_compare={'tweet': 'https://twitter.com/kuyacoy/status/1581185279376838657', 'url': '', 'description': "ngl, I'm scared on finding out the cute Sprigatito's final evolution..\n\nso i had a bot generate it for me.... and I'm forever scarred https://t.co/itMay87vcS", 'thumbnail': 'https://pbs.twimg.com/media/FfF_gKwXgAIpnpD.jpg', 'type': 'Image', 'images': ['https://pbs.twimg.com/media/FfF_gKwXgAIpnpD.jpg', '', '', '', '1'], 'time': 'Sat Oct 15 07:28:42 +0000 2022', 'qrtURL': None, 'nsfw': True, 'size': {}, 'isGif': False}
|
||||
|
||||
|
||||
testUser="https://twitter.com/jack"
|
||||
testUserID = "https://twitter.com/i/user/12"
|
||||
testUserWeirdURLs=["https://twitter.com/jack?lang=en","https://twitter.com/jack/with_replies","https://twitter.com/jack/media","https://twitter.com/jack/likes","https://twitter.com/jack/with_replies?lang=en","https://twitter.com/jack/media?lang=en","https://twitter.com/jack/likes?lang=en","https://twitter.com/jack/"]
|
||||
testTextTweet="https://twitter.com/jack/status/20"
|
||||
testVideoTweet="https://twitter.com/Twitter/status/1263145271946551300"
|
||||
testMediaTweet="https://twitter.com/Twitter/status/1118295916874739714"
|
||||
testMultiMediaTweet="https://twitter.com/Twitter/status/1154172324599537665"
|
||||
testPollTweet="https://twitter.com/norm/status/651169346518056960"
|
||||
testQRTTweet="https://twitter.com/Twitter/status/1232823570046255104"
|
||||
testQrtCeptionTweet="https://twitter.com/CatherineShu/status/585253766271672320"
|
||||
testQrtVideoTweet="https://twitter.com/Twitter/status/1494436688554344449"
|
||||
|
||||
# I literally picked a random tweet that twitter marked as 'sensitive' without it being like, actually NSFW.
|
||||
# Any better suggestions for a tweet to use are welcome
|
||||
testNSFWTweet="https://twitter.com/kuyacoy/status/1581185279376838657"
|
||||
|
||||
textVNF_compare = {'tweet': 'https://twitter.com/jack/status/20', 'url': '', 'description': 'just setting up my twttr', 'screen_name': 'jack', 'type': 'Text', 'images': ['', '', '', '', ''], 'time': 'Tue Mar 21 20:50:14 +0000 2006', 'qrtURL': None, 'nsfw': False}
|
||||
videoVNF_compare={'tweet': 'https://twitter.com/Twitter/status/1263145271946551300', 'url': 'https://video.twimg.com/amplify_video/1263145212760805376/vid/1280x720/9jous8HM0_duxL0w.mp4?tag=13', 'description': 'Testing, testing...\n\nA new way to have a convo with exactly who you want. We’re starting with a small % globally, so keep your 👀 out to see it in action. https://t.co/pV53mvjAVT', 'thumbnail': 'https://pbs.twimg.com/media/EYeX7akWsAIP1_1.jpg', 'screen_name': twitterAccountName, 'type': 'Video', 'images': ['', '', '', '', ''], 'time': 'Wed May 20 16:31:15 +0000 2020', 'qrtURL': None, 'nsfw': False,'verified': True, 'size': {'width': 1920, 'height': 1080}}
|
||||
testMedia_compare={'tweet': 'https://twitter.com/Twitter/status/1118295916874739714', 'url': '', 'description': 'On profile pages, we used to only show someone’s replies, not the original Tweet 🙄 Now we’re showing both so you can follow the conversation more easily! https://t.co/LSBEZYFqmY', 'thumbnail': 'https://pbs.twimg.com/media/D4TS4xeX4AA02DI.jpg', 'screen_name': twitterAccountName, 'type': 'Image', 'images': ['https://pbs.twimg.com/media/D4TS4xeX4AA02DI.jpg', '', '', '', '1'], 'time': 'Tue Apr 16 23:31:38 +0000 2019', 'qrtURL': None, 'nsfw': False, 'size': {}}
|
||||
testMultiMedia_compare={'tweet': 'https://twitter.com/Twitter/status/1154172324599537665', 'url': '', 'description': '10 days. 40 cities. Virtual #Tweetups are happening around the world. Join us and follow the convo! \nhttp://sharedstudios.com/tweetups https://t.co/M436G4fVio', 'thumbnail': 'https://pbs.twimg.com/media/EARxm9FXYAA8qqz.jpg', 'screen_name': twitterAccountName, 'type': 'Image', 'images': ['https://pbs.twimg.com/media/EARxm9FXYAA8qqz.jpg', 'https://pbs.twimg.com/media/EARxm9GW4AEnQkp.jpg', 'https://pbs.twimg.com/media/EARxm9HXkAEEsM0.jpg', 'https://pbs.twimg.com/media/EARxm9QXkAAZIA4.jpg', '4'], 'qrtURL': None, 'nsfw': False, 'verified': True, 'size': {}}
|
||||
|
||||
testPoll_comparePoll={"name":"poll2choice_text_only","binding_values":{"choice1_label":{"type":"STRING","string_value":"Mean one thing"},"choice2_label":{"type":"STRING","string_value":"Mean multiple things"},"end_datetime_utc":{"type":"STRING","string_value":"2015-10-06T22:57:24Z"},"counts_are_final":{"type":"BOOLEAN","boolean_value":True},"choice2_count":{"type":"STRING","string_value":"33554"},"choice1_count":{"type":"STRING","string_value":"124875"},"last_updated_datetime_utc":{"type":"STRING","string_value":"2015-10-06T22:57:31Z"},"duration_minutes":{"type":"STRING","string_value":"1440"}}}
|
||||
testPoll_comparePollVNF={'total_votes': 158429, 'choices': [{'text': 'Mean one thing', 'votes': 124875, 'percent': 78.8}, {'text': 'Mean multiple things', 'votes': 33554, 'percent': 21.2}]}
|
||||
@ -47,16 +50,16 @@ def compareDict(original,compare):
|
||||
## Specific API tests ##
|
||||
def test_syndicationAPI():
|
||||
tweet = twExtract.extractStatus_syndication(testMediaTweet,workaroundTokens=tokens)
|
||||
assert tweet["full_text"]==testMedia_compare['description']
|
||||
assert tweet["full_text"]==testMediaTweet_compare['description']
|
||||
|
||||
def test_v2API():
|
||||
tweet = twExtract.extractStatusV2Legacy(testMediaTweet,workaroundTokens=tokens)
|
||||
assert tweet["full_text"]==testMedia_compare['description']
|
||||
assert tweet["full_text"]==testMediaTweet_compare['description']
|
||||
|
||||
## Tweet retrieve tests ##
|
||||
def test_textTweetExtract():
|
||||
tweet = twExtract.extractStatus(testTextTweet,workaroundTokens=tokens)
|
||||
assert tweet["full_text"]==textVNF_compare['description']
|
||||
assert tweet["full_text"]==testTextTweet_compare['description']
|
||||
assert tweet["user"]["screen_name"]=="jack"
|
||||
assert 'extended_entities' not in tweet
|
||||
|
||||
@ -84,37 +87,34 @@ def test_UserExtractWeirdURLs():
|
||||
|
||||
def test_videoTweetExtract():
|
||||
tweet = twExtract.extractStatus(testVideoTweet,workaroundTokens=tokens)
|
||||
assert tweet["full_text"]==videoVNF_compare['description']
|
||||
assert tweet["user"]["screen_name"]==twitterAccountName
|
||||
assert tweet["full_text"]==testVideoTweet_compare['description']
|
||||
assert 'extended_entities' in tweet
|
||||
assert len(tweet['extended_entities']["media"])==1
|
||||
video = tweet['extended_entities']["media"][0]
|
||||
assert video["media_url_https"]=="https://pbs.twimg.com/media/EYeX7akWsAIP1_1.jpg"
|
||||
assert video["media_url_https"]==testVideoTweet_compare['thumbnail']
|
||||
assert video["type"]=="video"
|
||||
|
||||
|
||||
def test_mediaTweetExtract():
|
||||
tweet = twExtract.extractStatus(testMediaTweet,workaroundTokens=tokens)
|
||||
assert tweet["full_text"]==testMedia_compare['description']
|
||||
assert tweet["user"]["screen_name"]==twitterAccountName
|
||||
assert tweet["full_text"]==testMediaTweet_compare['description']
|
||||
assert 'extended_entities' in tweet
|
||||
assert len(tweet['extended_entities']["media"])==1
|
||||
video = tweet['extended_entities']["media"][0]
|
||||
assert video["media_url_https"]=="https://pbs.twimg.com/media/D4TS4xeX4AA02DI.jpg"
|
||||
assert video["media_url_https"]==testMediaTweet_compare['thumbnail']
|
||||
assert video["type"]=="photo"
|
||||
|
||||
|
||||
def test_multimediaTweetExtract():
|
||||
tweet = twExtract.extractStatus(testMultiMediaTweet,workaroundTokens=tokens)
|
||||
assert tweet["full_text"][:94]==testMultiMedia_compare['description'][:94]
|
||||
assert tweet["user"]["screen_name"]==twitterAccountName
|
||||
assert tweet["full_text"][:94]==testMultiMediaTweet_compare['description'][:94]
|
||||
assert 'extended_entities' in tweet
|
||||
assert len(tweet['extended_entities']["media"])==4
|
||||
assert len(tweet['extended_entities']["media"])==3
|
||||
video = tweet['extended_entities']["media"][0]
|
||||
assert video["media_url_https"]=="https://pbs.twimg.com/media/EARxm9FXYAA8qqz.jpg"
|
||||
assert video["media_url_https"]==testMultiMediaTweet_compare["images"][0]
|
||||
assert video["type"]=="photo"
|
||||
video = tweet['extended_entities']["media"][1]
|
||||
assert video["media_url_https"]=="https://pbs.twimg.com/media/EARxm9GW4AEnQkp.jpg"
|
||||
assert video["media_url_https"]==testMultiMediaTweet_compare["images"][1]
|
||||
assert video["type"]=="photo"
|
||||
|
||||
def test_pollTweetExtract():
|
||||
@ -128,20 +128,20 @@ def test_NSFW_TweetExtract():
|
||||
## VNF conversion test ##
|
||||
def test_textTweetVNF():
|
||||
vnf = twitfix.link_to_vnf_from_unofficial_api(testTextTweet)
|
||||
compareDict(textVNF_compare,vnf)
|
||||
compareDict(testTextTweet_compare,vnf)
|
||||
|
||||
def test_videoTweetVNF():
|
||||
vnf = twitfix.link_to_vnf_from_unofficial_api(testVideoTweet)
|
||||
|
||||
compareDict(videoVNF_compare,vnf)
|
||||
compareDict(testVideoTweet_compare,vnf)
|
||||
|
||||
def test_mediaTweetVNF():
|
||||
vnf = twitfix.link_to_vnf_from_unofficial_api(testMediaTweet)
|
||||
compareDict(testMedia_compare,vnf)
|
||||
compareDict(testMediaTweet_compare,vnf)
|
||||
|
||||
def test_multimediaTweetVNF():
|
||||
vnf = twitfix.link_to_vnf_from_unofficial_api(testMultiMediaTweet)
|
||||
compareDict(testMultiMedia_compare,vnf)
|
||||
compareDict(testMultiMediaTweet_compare,vnf)
|
||||
|
||||
def test_pollTweetVNF():
|
||||
vnf = twitfix.link_to_vnf_from_unofficial_api(testPollTweet)
|
||||
@ -152,7 +152,7 @@ def test_qrtTweet():
|
||||
# this is an incredibly lazy test, todo: improve it in the future
|
||||
resp = client.get(testQRTTweet.replace("https://twitter.com",""),headers={"User-Agent":"test"})
|
||||
assert resp.status_code==200
|
||||
assert "Twitter says I have 382 followers" in str(resp.data)
|
||||
assert testQRTTweet_compare['description'][:10] in str(resp.data)
|
||||
# test qrt-ception
|
||||
resp = client.get(testQrtCeptionTweet.replace("https://twitter.com",""),headers={"User-Agent":"test"}) # get top level tweet
|
||||
assert resp.status_code==200
|
||||
@ -170,7 +170,8 @@ def test_qrtVideoTweet():
|
||||
# this is an incredibly lazy test, todo: improve it in the future
|
||||
resp = client.get(testQrtVideoTweet.replace("https://twitter.com",""),headers={"User-Agent":"test"})
|
||||
assert resp.status_code==200
|
||||
assert "twitter:player:stream\" content=\"https://video.twimg.com/tweet_video/FL0gdK8WUAIHHKa.mp4" in str(resp.data)
|
||||
vurl = testQrtVideoTweet_compare["url"]
|
||||
assert f"twitter:player:stream\" content=\"{vurl}" in str(resp.data)
|
||||
|
||||
## Test adding to cache ; cache should be empty ##
|
||||
def test_addToCache():
|
||||
@ -180,10 +181,10 @@ def test_addToCache():
|
||||
twitfix.vnfFromCacheOrDL(testMediaTweet)
|
||||
twitfix.vnfFromCacheOrDL(testMultiMediaTweet)
|
||||
#retrieve
|
||||
compareDict(textVNF_compare,cache.getVnfFromLinkCache(testTextTweet))
|
||||
compareDict(videoVNF_compare,cache.getVnfFromLinkCache(testVideoTweet))
|
||||
compareDict(testMedia_compare,cache.getVnfFromLinkCache(testMediaTweet))
|
||||
compareDict(testMultiMedia_compare,cache.getVnfFromLinkCache(testMultiMediaTweet))
|
||||
compareDict(testTextTweet_compare,cache.getVnfFromLinkCache(testTextTweet))
|
||||
compareDict(testVideoTweet_compare,cache.getVnfFromLinkCache(testVideoTweet))
|
||||
compareDict(testMediaTweet_compare,cache.getVnfFromLinkCache(testMediaTweet))
|
||||
compareDict(testMultiMediaTweet_compare,cache.getVnfFromLinkCache(testMultiMediaTweet))
|
||||
cache.clearCache()
|
||||
|
||||
def test_embedFromScratch():
|
||||
@ -224,11 +225,11 @@ def test_veryLongEmbed():
|
||||
assert resp.status_code==200
|
||||
|
||||
def test_embedFromOutdatedCache(): # presets a cache that has VNF's with missing fields; there's probably a better way to do this
|
||||
cache.setCache({"https://twitter.com/Twitter/status/1118295916874739714":{"description":"On profile pages, we used to only show someone’s replies, not the original Tweet 🙄 Now we’re showing both so you can follow the conversation more easily! https://t.co/LSBEZYFqmY","hits":0,"images":["https://pbs.twimg.com/media/D4TS4xeX4AA02DI.jpg","","","","1"],"likes":5033,"nsfw":False,"pfp":"https://pbs.twimg.com/profile_images/1488548719062654976/u6qfBBkF_normal.jpg","qrt":{},"rts":754,"screen_name":twitterAccountName,"thumbnail":"https://pbs.twimg.com/media/D4TS4xeX4AA02DI.jpg","time":"Tue Apr 16 23:31:38 +0000 2019","tweet":"https://twitter.com/Twitter/status/1118295916874739714","type":"Image","uploader":twitterAccountName,"url":""},
|
||||
"https://twitter.com/Twitter/status/1263145271946551300":{"description":"Testing, testing...\n\nA new way to have a convo with exactly who you want. We’re starting with a small % globally, so keep your 👀 out to see it in action. https://t.co/pV53mvjAVT","hits":0,"images":["","","","",""],"likes":61584,"nsfw":False,"pfp":"https://pbs.twimg.com/profile_images/1488548719062654976/u6qfBBkF_normal.jpg","qrt":{},"rts":17138,"screen_name":twitterAccountName,"thumbnail":"https://pbs.twimg.com/media/EYeX7akWsAIP1_1.jpg","time":"Wed May 20 16:31:15 +0000 2020","tweet":"https://twitter.com/Twitter/status/1263145271946551300","type":"Video","uploader":twitterAccountName,"url":"https://video.twimg.com/amplify_video/1263145212760805376/vid/1280x720/9jous8HM0_duxL0w.mp4?tag=13"},
|
||||
cache.setCache({"https://twitter.com/Twitter/status/1118295916874739714":{"description":"On profile pages, we used to only show someone’s replies, not the original Tweet 🙄 Now we’re showing both so you can follow the conversation more easily! https://t.co/LSBEZYFqmY","hits":0,"images":["https://pbs.twimg.com/media/D4TS4xeX4AA02DI.jpg","","","","1"],"likes":5033,"nsfw":False,"pfp":"https://pbs.twimg.com/profile_images/1488548719062654976/u6qfBBkF_normal.jpg","qrt":{},"rts":754,"screen_name":'Twitter',"thumbnail":"https://pbs.twimg.com/media/D4TS4xeX4AA02DI.jpg","time":"Tue Apr 16 23:31:38 +0000 2019","tweet":"https://twitter.com/Twitter/status/1118295916874739714","type":"Image","uploader":'Twitter',"url":""},
|
||||
"https://twitter.com/Twitter/status/1263145271946551300":{"description":"Testing, testing...\n\nA new way to have a convo with exactly who you want. We’re starting with a small % globally, so keep your 👀 out to see it in action. https://t.co/pV53mvjAVT","hits":0,"images":["","","","",""],"likes":61584,"nsfw":False,"pfp":"https://pbs.twimg.com/profile_images/1488548719062654976/u6qfBBkF_normal.jpg","qrt":{},"rts":17138,"screen_name":'Twitter',"thumbnail":"https://pbs.twimg.com/media/EYeX7akWsAIP1_1.jpg","time":"Wed May 20 16:31:15 +0000 2020","tweet":"https://twitter.com/Twitter/status/1263145271946551300","type":"Video","uploader":'Twitter',"url":"https://video.twimg.com/amplify_video/1263145212760805376/vid/1280x720/9jous8HM0_duxL0w.mp4?tag=13"},
|
||||
#"https://twitter.com/Twitter/status/1293239745695211520":{"description":"We tested, you Tweeted, and now we’re rolling it out to everyone! https://t.co/w6Q3Q6DiKz","hits":0,"images":["https://pbs.twimg.com/media/EfJ-C-JU0AAQL_C.jpg","https://pbs.twimg.com/media/EfJ-aHlU0AAU1kq.jpg","","","2"],"likes":5707,"nsfw":False,"pfp":"https://pbs.twimg.com/profile_images/1488548719062654976/u6qfBBkF_normal.jpg","qrt":{},"rts":1416,"screen_name":"Twitter","thumbnail":"https://pbs.twimg.com/media/EfJ-C-JU0AAQL_C.jpg","time":"Tue Aug 11 17:35:57 +0000 2020","tweet":"https://twitter.com/Twitter/status/1293239745695211520","type":"Image","uploader":"Twitter","url":""},
|
||||
"https://twitter.com/jack/status/20":{"description":"just setting up my twttr","hits":0,"images":["","","","",""],"likes":179863,"nsfw":False,"pfp":"https://pbs.twimg.com/profile_images/1115644092329758721/AFjOr-K8_normal.jpg","qrt":{},"rts":122021,"screen_name":"jack","thumbnail":"","time":"Tue Mar 21 20:50:14 +0000 2006","tweet":"https://twitter.com/jack/status/20","type":"Text","uploader":"jack","url":""},
|
||||
testQrtVideoTweet:{'tweet': 'https://twitter.com/Twitter/status/1494436688554344449', 'url': '', 'description': 'https://twitter.com/TwitterSupport/status/1494386367467593737', 'thumbnail': '', 'uploader': twitterAccountName, 'screen_name': twitterAccountName, 'pfp': 'https://pbs.twimg.com/profile_images/1488548719062654976/u6qfBBkF_normal.jpg', 'type': 'Text', 'images': ['', '', '', '', ''], 'likes': 5186, 'rts': 703, 'time': 'Thu Feb 17 22:20:46 +0000 2022', 'qrt': {'desc': 'Keep your fave DM convos easily accessible by pinning them! You can now pin up to six conversations that will stay at the top of your DM inbox.\n\nAvailable on Android, iOS, and web. https://t.co/kIjlzf9XLJ', 'handle': 'Twitter Support', 'screen_name': 'TwitterSupport', 'verified': True, 'id': '1494386367467593737'}, 'nsfw': False, 'verified': True, 'size': {}}
|
||||
testQrtVideoTweet:{'tweet': 'https://twitter.com/Twitter/status/1494436688554344449', 'url': '', 'description': 'https://twitter.com/TwitterSupport/status/1494386367467593737', 'thumbnail': '', 'uploader': 'Twitter', 'screen_name': 'Twitter', 'pfp': 'https://pbs.twimg.com/profile_images/1488548719062654976/u6qfBBkF_normal.jpg', 'type': 'Text', 'images': ['', '', '', '', ''], 'likes': 5186, 'rts': 703, 'time': 'Thu Feb 17 22:20:46 +0000 2022', 'qrt': {'desc': 'Keep your fave DM convos easily accessible by pinning them! You can now pin up to six conversations that will stay at the top of your DM inbox.\n\nAvailable on Android, iOS, and web. https://t.co/kIjlzf9XLJ', 'handle': 'Twitter Support', 'screen_name': 'TwitterSupport', 'verified': True, 'id': '1494386367467593737'}, 'nsfw': False, 'verified': True, 'size': {}}
|
||||
})
|
||||
#embed time
|
||||
resp = client.get(testTextTweet.replace("https://twitter.com",""),headers={"User-Agent":"test"})
|
||||
@ -248,7 +249,7 @@ def test_embedFromOutdatedCache(): # presets a cache that has VNF's with missing
|
||||
def test_directEmbed():
|
||||
resp = client.get(testVideoTweet.replace("https://twitter.com","")+".mp4",headers={"User-Agent":"test"})
|
||||
assert resp.status_code==200
|
||||
assert videoVNF_compare["url"] in str(resp.data)
|
||||
assert testVideoTweet_compare["url"] in str(resp.data)
|
||||
|
||||
def test_message404():
|
||||
resp = client.get("https://twitter.com/jack/status/12345",headers={"User-Agent":"test"})
|
||||
|
30
testgen.py
Normal file
30
testgen.py
Normal file
@ -0,0 +1,30 @@
|
||||
import twitfix
|
||||
|
||||
tests = {
|
||||
"testTextTweet":"https://twitter.com/jack/status/20",
|
||||
"testVideoTweet":"https://twitter.com/pdxdylan/status/1540398733669666818",
|
||||
"testMediaTweet":"https://twitter.com/pdxdylan/status/1534672932106035200",
|
||||
"testMultiMediaTweet":"https://twitter.com/pdxdylan/status/1532006436703715331",
|
||||
"testQRTTweet":"https://twitter.com/pdxdylan/status/1611477137319514129",
|
||||
"testQrtCeptionTweet":"https://twitter.com/CatherineShu/status/585253766271672320",
|
||||
"testQrtVideoTweet":"https://twitter.com/pdxdylan/status/1674561759422578690",
|
||||
"testNSFWTweet":"https://twitter.com/kuyacoy/status/1581185279376838657"
|
||||
}
|
||||
|
||||
with open('generated.txt', 'w',encoding='utf-8') as f:
|
||||
f.write("# autogenerated from testgen.py\n")
|
||||
for test in tests:
|
||||
f.write(f"{test}=\"{tests[test]}\"\n")
|
||||
f.write("\n")
|
||||
for test in tests:
|
||||
VNF = twitfix.link_to_vnf(tests[test])
|
||||
del VNF['ttl']
|
||||
del VNF['likes']
|
||||
del VNF['rts']
|
||||
del VNF['hits']
|
||||
del VNF['pfp']
|
||||
del VNF['uploader']
|
||||
del VNF['verified']
|
||||
del VNF['screen_name']
|
||||
# write in a format that can be copy-pasted into a python file, i.e testTextTweet={...
|
||||
f.write(f"{test}_compare={VNF}\n")
|
Loading…
x
Reference in New Issue
Block a user