Files
Portable-Computing-Toolkit-…/portable_computing_toolkit_installer/tests/test_json.py
2019-05-01 17:03:57 -04:00

31 lines
832 B
Python

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