checkpoint. beginning download process
This commit is contained in:
30
portable_computing_toolkit_installer/tests/test_json.py
Normal file
30
portable_computing_toolkit_installer/tests/test_json.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import json
|
||||
from urllib.parse import urlparse
|
||||
from urllib.request import urlopen
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
json_url = "https://raw.githubusercontent.com/norweeg/portable-computing-toolkit-installer/initial_dev/portable_computing_toolkit_installer/resources/supported_tools.json"
|
||||
|
||||
class TestJSON(object):
|
||||
def test_json_url_valid(self):
|
||||
global json_url
|
||||
parsed = urlparse(json_url)
|
||||
assert len(parsed) == 6
|
||||
assert Path(parsed.path).suffix == ".json"
|
||||
|
||||
def test_json_accessible(self):
|
||||
global json_url
|
||||
json_file = urlopen(json_url)
|
||||
assert json_file.code < 400
|
||||
json_file.close()
|
||||
|
||||
def test_json_valid(self):
|
||||
global json_url
|
||||
with urlopen(json_url) as json_file:
|
||||
json_data = json.load(json_file)
|
||||
assert json_data
|
||||
|
||||
|
||||
26
portable_computing_toolkit_installer/tests/test_pages.py
Normal file
26
portable_computing_toolkit_installer/tests/test_pages.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import json
|
||||
from urllib.request import urlopen
|
||||
import requests
|
||||
from pathlib import Path
|
||||
from parsel import Selector
|
||||
from w3lib.url import canonicalize_url
|
||||
|
||||
import pytest
|
||||
|
||||
json_url = "https://raw.githubusercontent.com/norweeg/portable-computing-toolkit-installer/initial_dev/portable_computing_toolkit_installer/resources/supported_tools.json"
|
||||
|
||||
class TestPages(object):
|
||||
def test_pages_accessible(self):
|
||||
global json_url
|
||||
with urlopen(json_url) as json_file:
|
||||
json_data = json.load(json_file)
|
||||
with requests.Session() as session:
|
||||
for page in [canonicalize_url(item["homepage"]) for item in json_data]:
|
||||
try:
|
||||
response = session.get(page, allow_redirects = True, verify = False)
|
||||
except:
|
||||
response = session.get(page.replace("http", "https", 1), allow_redirects = True, verify = False)
|
||||
assert response.status_code < 400
|
||||
html = response.text
|
||||
assert html
|
||||
assert Selector(text = html, type="html").getall()
|
||||
Reference in New Issue
Block a user