Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/pypi/tests/test_pypi.py
Show First 20 Lines • Show All 842 Lines • ▼ Show 20 Lines | Platform: UNKNOWN""" | ||||
directory = hash_to_bytes("8b864d66f356afe35033d58f8e03b7c23a66751f") | directory = hash_to_bytes("8b864d66f356afe35033d58f8e03b7c23a66751f") | ||||
# attempt to build revision | # attempt to build revision | ||||
loader = PyPILoader(swh_storage, url) | loader = PyPILoader(swh_storage, url) | ||||
revision = loader.build_revision(p_info, str(tmp_path), directory) | revision = loader.build_revision(p_info, str(tmp_path), directory) | ||||
# without comment_text and version in PKG-INFO, message should be empty | # without comment_text and version in PKG-INFO, message should be empty | ||||
assert revision.message == b"" | assert revision.message == b"" | ||||
def test_filter_out_invalid_sdists(swh_storage, requests_mock): | |||||
project_name = "swh-test-sdist-filtering" | |||||
version = "1.0.0" | |||||
url = f"https://pypi.org/project/{project_name}" | |||||
json_url = f"https://pypi.org/pypi/{project_name}/json" | |||||
common_sdist_entries = { | |||||
"url": "", | |||||
"comment_text": "", | |||||
"digests": {"sha256": ""}, | |||||
"upload_time": "", | |||||
"packagetype": "sdist", | |||||
} | |||||
requests_mock.get( | |||||
json_url, | |||||
json={ | |||||
"releases": { | |||||
version: [ | |||||
{ | |||||
**common_sdist_entries, | |||||
"filename": f"{project_name}-{version}.{ext}", | |||||
} | |||||
for ext in ("tar.gz", "deb", "egg", "rpm", "whl") | |||||
] | |||||
}, | |||||
}, | |||||
) | |||||
loader = PyPILoader(swh_storage, url) | |||||
packages = list(loader.get_package_info(version=version)) | |||||
assert len(packages) == 1 | |||||
assert packages[0][1].filename.endswith(".tar.gz") |