Misc. changes and coverage excludes

This commit is contained in:
Dylan 2022-09-28 23:50:12 +01:00
parent 23b68e4634
commit 6e1f37eabd
5 changed files with 9 additions and 13 deletions

2
.gitignore vendored
View File

@ -9,3 +9,5 @@ admin.env
_meta _meta
.serverless .serverless
db/ db/
.coverage
htmlcov/

View File

@ -8,7 +8,7 @@ import boto3
link_cache_system = config['config']['link_cache'] link_cache_system = config['config']['link_cache']
DYNAMO_CACHE_TBL=None DYNAMO_CACHE_TBL=None
if link_cache_system=="dynamodb": if link_cache_system=="dynamodb": # pragma: no cover
DYNAMO_CACHE_TBL=config['config']['table'] DYNAMO_CACHE_TBL=config['config']['table']
if link_cache_system == "json": if link_cache_system == "json":
@ -35,7 +35,7 @@ elif link_cache_system == "db":
client = pymongo.MongoClient(config['config']['database'], connect=False) client = pymongo.MongoClient(config['config']['database'], connect=False)
table = config['config']['table'] table = config['config']['table']
db = client[table] db = client[table]
elif link_cache_system == "dynamodb": elif link_cache_system == "dynamodb": # pragma: no cover
client = boto3.resource('dynamodb') client = boto3.resource('dynamodb')
def serializeUnknown(obj): def serializeUnknown(obj):
@ -57,7 +57,7 @@ def addVnfToLinkCache(video_link, vnf):
return None return None
elif link_cache_system == "ram": # FOR TESTS ONLY elif link_cache_system == "ram": # FOR TESTS ONLY
link_cache[video_link] = vnf link_cache[video_link] = vnf
elif link_cache_system == "dynamodb": elif link_cache_system == "dynamodb": # pragma: no cover
vnf["ttl"] = int(vnf["ttl"].strftime('%s')) vnf["ttl"] = int(vnf["ttl"].strftime('%s'))
table = client.Table(DYNAMO_CACHE_TBL) table = client.Table(DYNAMO_CACHE_TBL)
table.put_item( table.put_item(
@ -98,7 +98,7 @@ def getVnfFromLinkCache(video_link):
else: else:
print(" ➤ [ X ] Link not in json cache") print(" ➤ [ X ] Link not in json cache")
return None return None
elif link_cache_system == "dynamodb": elif link_cache_system == "dynamodb": # pragma: no cover
table = client.Table(DYNAMO_CACHE_TBL) table = client.Table(DYNAMO_CACHE_TBL)
response = table.get_item( response = table.get_item(
Key={ Key={

View File

@ -3,7 +3,7 @@ import os
if ('RUNNING_TESTS' in os.environ): if ('RUNNING_TESTS' in os.environ):
config= {"config":{"link_cache":"ram","database":"","table":"","color":"","appname": "vxTwitter","repo": "https://github.com/dylanpdx/BetterTwitFix","url": "https://vxtwitter.com","combination_method": "local"}} config= {"config":{"link_cache":"ram","database":"","table":"","color":"","appname": "vxTwitter","repo": "https://github.com/dylanpdx/BetterTwitFix","url": "https://vxtwitter.com","combination_method": "local"}}
elif ('RUNNING_SERVERLESS' in os.environ and os.environ['RUNNING_SERVERLESS'] == '1'): elif ('RUNNING_SERVERLESS' in os.environ and os.environ['RUNNING_SERVERLESS'] == '1'): # pragma: no cover
config = { config = {
"config":{ "config":{
"link_cache":os.environ["VXTWITTER_LINK_CACHE"], "link_cache":os.environ["VXTWITTER_LINK_CACHE"],

1
run_tests.sh Normal file
View File

@ -0,0 +1 @@
pytest --cov-config=.coveragerc --cov=. --cov-report html

View File

@ -158,7 +158,7 @@ def dir(sub_path):
return redirect(url, 301) return redirect(url, 301)
@app.route('/favicon.ico') @app.route('/favicon.ico')
def favicon(): def favicon(): # pragma: no cover
return send_from_directory(os.path.join(app.root_path, 'static'), 'favicon.ico',mimetype='image/vnd.microsoft.icon') return send_from_directory(os.path.join(app.root_path, 'static'), 'favicon.ico',mimetype='image/vnd.microsoft.icon')
@app.route("/rendercombined.jpg") @app.route("/rendercombined.jpg")
@ -273,13 +273,6 @@ def tweetInfo(url, tweet="", desc="", thumb="", uploader="", screen_name="", pfp
} }
return vnf return vnf
def get_tweet_data_from_api(video_link):
print(" ➤ [ + ] Attempting to download tweet info from Twitter API")
twid = int(re.sub(r'\?.*$','',video_link.rsplit("/", 1)[-1])) # gets the tweet ID as a int from the passed url
tweet = twitter_api.statuses.show(_id=twid, tweet_mode="extended")
#print(tweet) # For when I need to poke around and see what a tweet looks like
return tweet
def link_to_vnf_from_tweet_data(tweet,video_link): def link_to_vnf_from_tweet_data(tweet,video_link):
imgs = ["","","","", ""] imgs = ["","","","", ""]
print(" ➤ [ + ] Tweet Type: " + tweetType(tweet)) print(" ➤ [ + ] Tweet Type: " + tweetType(tweet))