Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/tests/test_utils.py
Show All 33 Lines | def test_download_fail_to_download(tmp_path, requests_mock): | ||||
assert e.value.args[0] == "Fail to query '%s'. Reason: %s" % (url, status_code) | assert e.value.args[0] == "Fail to query '%s'. Reason: %s" % (url, status_code) | ||||
_filename = "requests-0.0.1.tar.gz" | _filename = "requests-0.0.1.tar.gz" | ||||
_data = "this is something" | _data = "this is something" | ||||
def _check_download_ok(url, dest, filename=_filename, hashes=None): | def _check_download_ok(url, dest, filename=_filename, hashes={}): | ||||
actual_filepath, actual_hashes = download(url, dest, hashes=hashes) | actual_filepath, actual_hashes = download(url, dest, hashes=hashes) | ||||
actual_filename = os.path.basename(actual_filepath) | actual_filename = os.path.basename(actual_filepath) | ||||
assert actual_filename == filename | assert actual_filename == filename | ||||
assert actual_hashes["length"] == len(_data) | assert actual_hashes["length"] == len(_data) | ||||
assert ( | assert ( | ||||
actual_hashes["checksums"]["sha1"] == "fdd1ce606a904b08c816ba84f3125f2af44d92b2" | actual_hashes["checksums"]["sha1"] == "fdd1ce606a904b08c816ba84f3125f2af44d92b2" | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines |