mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-17 23:45:21 +01:00
Tests if repository json files conform to the json schema. If all resources (images/icons/website URLs) they mention actually exists. And can also test writing images and the FAT modification code.
25 lines
692 B
Python
25 lines
692 B
Python
import urllib.request
|
|
|
|
def _head_request(url):
|
|
req = urllib.request.Request(
|
|
url,
|
|
data=None,
|
|
headers={
|
|
'User-Agent': 'rpi-imager automated tests'
|
|
},
|
|
method="HEAD"
|
|
)
|
|
return urllib.request.urlopen(req)
|
|
|
|
|
|
def test_icon_url_exists(iconurl):
|
|
assert _head_request(iconurl).status == 200
|
|
|
|
def test_website_url_exists(websiteurl):
|
|
assert _head_request(websiteurl).status == 200
|
|
|
|
def test_image_url_exists_and_has_correct_image_download_size(imageitem):
|
|
response = _head_request(imageitem["url"])
|
|
|
|
assert response.status == 200
|
|
assert str(imageitem["image_download_size"]) == response.headers["Content-Length"]
|