Direct embed and 404 tweet tests
This commit is contained in:
parent
777458e58f
commit
d680579d6a
2
msgs.py
2
msgs.py
@ -1,5 +1,7 @@
|
||||
failedToScan="Failed to scan your link! This may be due to an incorrect link, private/suspended account, deleted tweet, or Twitter itself might be having issues (Check here: https://api.twitterstat.us/)"
|
||||
failedToScanExtra = "\n\nTwitter gave me this error: "
|
||||
tweetNotFound="Tweet not found."
|
||||
tweetSuspended="This Tweet is from a suspended account."
|
||||
|
||||
def genLikesDisplay(vnf):
|
||||
return ("\n\n💖 " + str(vnf['likes']) + " 🔁 " + str(vnf['rts']) + "\n")
|
||||
|
15
test_vx.py
15
test_vx.py
@ -3,9 +3,8 @@ from wsgiref import headers
|
||||
os.environ["RUNNING_TESTS"]="1"
|
||||
|
||||
import twitfix,twExtract
|
||||
import pytest
|
||||
import json
|
||||
import cache
|
||||
import msgs
|
||||
from flask.testing import FlaskClient
|
||||
client = FlaskClient(twitfix.app)
|
||||
|
||||
@ -133,4 +132,14 @@ def test_embedFromOutdatedCache(): # presets a cache that has VNF's with missing
|
||||
resp = client.get(testMediaTweet.replace("https://twitter.com",""),headers={"User-Agent":"test"})
|
||||
assert resp.status_code==200
|
||||
resp = client.get(testMultiMediaTweet.replace("https://twitter.com",""),headers={"User-Agent":"test"})
|
||||
assert resp.status_code==200
|
||||
assert resp.status_code==200
|
||||
|
||||
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)
|
||||
|
||||
def test_message404():
|
||||
resp = client.get("https://twitter.com/jack/status/12345",headers={"User-Agent":"test"})
|
||||
assert resp.status_code==200
|
||||
assert msgs.tweetNotFound in str(resp.data)
|
@ -208,9 +208,9 @@ def vnfFromCacheOrDL(video_link):
|
||||
return vnf,None
|
||||
except ExtractorError as exErr:
|
||||
if 'HTTP Error 404' in exErr.msg:
|
||||
exErr.msg="Tweet not found."
|
||||
exErr.msg=msgs.tweetNotFound
|
||||
elif 'suspended' in exErr.msg:
|
||||
exErr.msg="This Tweet is from a suspended account."
|
||||
exErr.msg=msgs.tweetSuspended
|
||||
else:
|
||||
exErr.msg=None
|
||||
return None,exErr.msg
|
||||
|
Loading…
x
Reference in New Issue
Block a user