Skip to content

Commit ce98912

Browse files
committed
tmp
1 parent 376106b commit ce98912

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

pulp_python/app/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ def parse_metadata(project, version, distribution):
158158
package["url"] = distribution.get("url") or ""
159159
package["sha256"] = distribution.get("digests", {}).get("sha256") or ""
160160
package["python_version"] = distribution.get("python_version") or package.get("python_version")
161-
package["requires_python"] = distribution.get("requires_python") or package.get(
162-
"requires_python"
163-
) # noqa: E501
161+
package["requires_python"] = distribution.get("requires_python") or "" # package.get(
162+
# "requires_python"
163+
# ) # noqa: E501
164164
package["metadata_sha256"] = distribution.get("data-dist-info-metadata", {}).get(
165165
"sha256"
166166
) or package.get("metadata_sha256")
@@ -448,7 +448,7 @@ def write_simple_detail_json(project_name, project_packages):
448448
"filename": package["filename"],
449449
"url": package["url"],
450450
"hashes": {"sha256": package["sha256"]},
451-
"requires_python": package["requires_python"] or None,
451+
"requires-python": package["requires_python"] or None,
452452
# data-dist-info-metadata is deprecated alias for core-metadata
453453
"data-dist-info-metadata": (
454454
{"sha256": package["metadata_sha256"]} if package["metadata_sha256"] else False

pulp_python/tests/functional/api/test_pypi_simple_json_api.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_simple_json_detail_api(
4444
repo = python_repo_with_sync(remote)
4545
distro = python_distribution_factory(repository=repo)
4646

47-
url = f'{urljoin(distro.base_url, "simple/")}aiohttp'
47+
url = f'{urljoin(distro.base_url, "simple/")}django'
4848
headers = {"Accept": PYPI_SIMPLE_V1_JSON}
4949

5050
response = requests.get(url, headers=headers)
@@ -53,17 +53,30 @@ def test_simple_json_detail_api(
5353

5454
data = response.json()
5555
assert data["meta"] == {"api-version": API_VERSION, "_last-serial": PYPI_SERIAL_CONSTANT}
56-
assert data["name"] == "aiohttp"
56+
assert data["name"] == "django"
5757
assert data["files"]
58-
for file in data["files"]:
59-
for i in [
60-
"filename",
61-
"url",
62-
"hashes",
63-
"data-dist-info-metadata",
64-
"requires_python",
65-
]:
66-
assert i in file
58+
59+
# Check data of a wheel file
60+
file_whl = next(
61+
(i for i in data["files"] if i["filename"] == "Django-1.10.4-py2.py3-none-any.whl"), None
62+
)
63+
assert file_whl is not None, "wheel file not found"
64+
assert file_whl["url"]
65+
assert file_whl["hashes"] == {
66+
"sha256": "a8e1a552205cda15023c39ecf17f7e525e96c5b0142e7879e8bd0c445351f2cc"
67+
}
68+
assert file_whl["requires-python"] is None
69+
assert file_whl["data-dist-info-metadata"] is False # todo: wrong
70+
71+
# Check data of a tar file
72+
file_tar = next((i for i in data["files"] if i["filename"] == "Django-1.10.4.tar.gz"), None)
73+
assert file_tar is not None, "tar file not found"
74+
assert file_tar["url"]
75+
assert file_tar["hashes"] == {
76+
"sha256": "fff7f062e510d812badde7cfc57745b7779edb4d209b2bc5ea8d954c22305c2b"
77+
}
78+
assert file_tar["requires-python"] is None
79+
assert file_tar["data-dist-info-metadata"] is False
6780

6881

6982
@pytest.mark.parallel

0 commit comments

Comments
 (0)