Fix tests and bugs

This commit is contained in:
Dylan 2024-05-17 17:13:03 +01:00
parent af4520eb3a
commit fc0ddcdf39
2 changed files with 8 additions and 8 deletions

View File

@ -74,39 +74,39 @@ def test_embed_video_direct_subdomain():
def test_embed_img_direct():
resp = client.get(testMediaTweet.replace("https://twitter.com","")+".png",headers={"User-Agent":"test"})
assert resp.status_code==302
assert resp.status_code==200
assert testMediaTweet_compare["mediaURLs"][0] in str(resp.data)
def test_embed_img_direct_subdomain():
resp = client.get(testMediaTweet.replace("https://twitter.com","https://d.vxtwitter.com"),headers={"User-Agent":"test"})
assert resp.status_code==302
assert resp.status_code==200
assert testMediaTweet_compare["mediaURLs"][0] in str(resp.data)
def test_embed_multi_direct():
# embed first item
resp = client.get(testMultiMediaTweet.replace("https://twitter.com","")+"/1.png",headers={"User-Agent":"test"})
assert resp.status_code==302 # images should redirect
assert resp.status_code==200
assert testMultiMediaTweet_compare["mediaURLs"][0] in str(resp.data)
# embed second item
resp = client.get(testMultiMediaTweet.replace("https://twitter.com","")+"/2.mp4",headers={"User-Agent":"test"})
assert resp.status_code==302 # images should redirect
assert resp.status_code==200
assert testMultiMediaTweet_compare["mediaURLs"][1] in str(resp.data)
def test_embed_multi_direct_subdomain():
# generic embed
resp = client.get(testMultiMediaTweet.replace("https://twitter.com","https://d.vxtwitter.com"),headers={"User-Agent":"test"})
assert resp.status_code==302 # images should redirect
assert resp.status_code==200
assert testMultiMediaTweet_compare["mediaURLs"][0] in str(resp.data)
# embed first item
resp = client.get(testMultiMediaTweet.replace("https://twitter.com","https://d.vxtwitter.com")+"/1",headers={"User-Agent":"test"})
assert resp.status_code==302 # images should redirect
assert resp.status_code==200
assert testMultiMediaTweet_compare["mediaURLs"][0] in str(resp.data)
# embed second item
resp = client.get(testMultiMediaTweet.replace("https://twitter.com","https://d.vxtwitter.com")+"/2",headers={"User-Agent":"test"})
assert resp.status_code==302 # images should redirect
assert resp.status_code==200
assert testMultiMediaTweet_compare["mediaURLs"][1] in str(resp.data)
def test_embed_message404():

View File

@ -187,7 +187,7 @@ def twitfix(sub_path):
if not tweetData['hasMedia'] and qrt is None:
return renderTextTweetEmbed(tweetData)
elif tweetData['allSameType'] and tweetData['media_extended'][0]['type'] == "image" and embedIndex == -1 and tweetData['combinedMediaUrl'] != None:
return redirect(tweetData['combinedMediaUrl'], 302)
return render_template("rawimage.html",media={"url":tweetData['combinedMediaUrl']})
else:
# this means we have mixed media or video, and we're only going to embed one
if embedIndex == -1: # if the user didn't specify an index, we'll just use the first one