Finalse pytest methods

This commit is contained in:
Leigh Morresi
2021-02-21 13:41:00 +01:00
parent b46a7fc4b1
commit 1718e2e86f
7 changed files with 161 additions and 73 deletions

View File

@@ -5,8 +5,6 @@ import os
import re
from inscriptis import get_text
from copy import deepcopy
# Some common stuff here that can be moved to a base class
class perform_site_check():
@@ -17,7 +15,6 @@ class perform_site_check():
def run(self, uuid):
timestamp = int(time.time()) # used for storage etc too
stripped_text_from_html = False
@@ -45,7 +42,9 @@ class perform_site_check():
timeout = 15
try:
r = requests.get(self.datastore.get_val(uuid, 'url'),
url = self.datastore.get_val(uuid, 'url')
r = requests.get(url,
headers=request_headers,
timeout=timeout,
verify=False)
@@ -53,7 +52,6 @@ class perform_site_check():
stripped_text_from_html = get_text(r.text)
# Usually from networkIO/requests level
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout) as e:
update_obj["last_error"] = str(e)
@@ -90,6 +88,7 @@ class perform_site_check():
if self.datastore.get_val(uuid, 'previous_md5'):
update_obj["last_changed"] = timestamp
update_obj["previous_md5"] = fetched_md5
update_obj["current_md5"] = fetched_md5
return update_obj, stripped_text_from_html