Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/tests/test_utils.py
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | def test_download_ok(tmp_path, requests_mock): | ||||
) # noqa | ) # noqa | ||||
assert ( | assert ( | ||||
actual_hashes["checksums"]["sha256"] | actual_hashes["checksums"]["sha256"] | ||||
== "1d9224378d77925d612c9f926eb9fb92850e6551def8328011b6a972323298d5" | == "1d9224378d77925d612c9f926eb9fb92850e6551def8328011b6a972323298d5" | ||||
) | ) | ||||
@pytest.mark.fs | @pytest.mark.fs | ||||
def test_download_no_url_schema(tmp_path, requests_mock): | |||||
url = "www.roudoudou.com/export/cpc/rasm/rasm_v0117_src.zip" | |||||
requests_mock.get(f"http://{url}", status_code=200) | |||||
download(url, dest=str(tmp_path)) | |||||
@pytest.mark.fs | |||||
def test_download_ok_no_header(tmp_path, requests_mock): | def test_download_ok_no_header(tmp_path, requests_mock): | ||||
"""Download without issue should provide filename and hashes""" | """Download without issue should provide filename and hashes""" | ||||
filename = "requests-0.0.1.tar.gz" | filename = "requests-0.0.1.tar.gz" | ||||
url = "https://pypi.org/pypi/requests/%s" % filename | url = "https://pypi.org/pypi/requests/%s" % filename | ||||
data = "this is something" | data = "this is something" | ||||
requests_mock.get(url, text=data) # no header information | requests_mock.get(url, text=data) # no header information | ||||
actual_filepath, actual_hashes = download(url, dest=str(tmp_path)) | actual_filepath, actual_hashes = download(url, dest=str(tmp_path)) | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |