forked from dylanpdx/BetterTwitFix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_api.py
38 lines (32 loc) · 1.82 KB
/
test_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from vx_testdata import *
import twitfix,twExtract
from flask.testing import FlaskClient
client = FlaskClient(twitfix.app)
def test_api_include_txt():
resp = client.get(testTextTweet.replace("https://twitter.com","https://api.vxtwitter.com")+"?include_txt=true",headers={"User-Agent":"test"})
jData = resp.get_json()
assert resp.status_code==200
assert any(".txt" in i for i in jData["mediaURLs"])
def test_api_include_rtf():
resp = client.get(testTextTweet.replace("https://twitter.com","https://api.vxtwitter.com")+"?include_rtf=true",headers={"User-Agent":"test"})
jData = resp.get_json()
assert resp.status_code==200
assert any(".rtf" in i for i in jData["mediaURLs"])
def test_api_include_txt_nomedia():
resp = client.get(testTextTweet.replace("https://twitter.com","https://api.vxtwitter.com")+"?include_txt=ifnomedia",headers={"User-Agent":"test"})
jData = resp.get_json()
assert resp.status_code==200
assert any(".txt" in i for i in jData["mediaURLs"])
resp = client.get(testMediaTweet.replace("https://twitter.com","https://api.vxtwitter.com")+"?include_txt=ifnomedia",headers={"User-Agent":"test"})
jData = resp.get_json()
assert resp.status_code==200
assert not any(".txt" in i for i in jData["mediaURLs"])
def test_api_include_rtf_nomedia():
resp = client.get(testTextTweet.replace("https://twitter.com","https://api.vxtwitter.com")+"?include_rtf=ifnomedia",headers={"User-Agent":"test"})
jData = resp.get_json()
assert resp.status_code==200
assert any(".rtf" in i for i in jData["mediaURLs"])
resp = client.get(testMediaTweet.replace("https://twitter.com","https://api.vxtwitter.com")+"?include_rtf=ifnomedia",headers={"User-Agent":"test"})
jData = resp.get_json()
assert resp.status_code==200
assert not any(".rtf" in i for i in jData["mediaURLs"])