44import requests
55
66from pulp_python .tests .functional .constants import PYTHON_SM_PROJECT_SPECIFIER
7+ from pulp_python .tests .functional .constants import (
8+ PYTHON_EGG_FILENAME ,
9+ PYTHON_EGG_URL ,
10+ PYTHON_WHEEL_FILENAME ,
11+ PYTHON_WHEEL_URL ,
12+ )
713
814API_VERSION = "1.0"
915PYPI_SERIAL_CONSTANT = 1000000000
@@ -38,13 +44,21 @@ def test_simple_json_index_api(
3844
3945@pytest .mark .parallel
4046def test_simple_json_detail_api (
41- python_remote_factory , python_repo_with_sync , python_distribution_factory
47+ monitor_task ,
48+ python_bindings ,
49+ python_content_factory ,
50+ python_distribution_factory ,
51+ python_repo_factory ,
4252):
43- remote = python_remote_factory (includes = PYTHON_SM_PROJECT_SPECIFIER )
44- repo = python_repo_with_sync (remote )
53+ content_1 = python_content_factory (PYTHON_EGG_FILENAME , url = PYTHON_EGG_URL )
54+ content_2 = python_content_factory (PYTHON_WHEEL_FILENAME , url = PYTHON_WHEEL_URL )
55+ body = {"add_content_units" : [content_1 .pulp_href , content_2 .pulp_href ]}
56+
57+ repo = python_repo_factory ()
58+ monitor_task (python_bindings .RepositoriesPythonApi .modify (repo .pulp_href , body ).task )
4559 distro = python_distribution_factory (repository = repo )
4660
47- url = f'{ urljoin (distro .base_url , "simple/" )} aiohttp '
61+ url = f'{ urljoin (distro .base_url , "simple/" )} shelf-reader '
4862 headers = {"Accept" : PYPI_SIMPLE_V1_JSON }
4963
5064 response = requests .get (url , headers = headers )
@@ -53,17 +67,32 @@ def test_simple_json_detail_api(
5367
5468 data = response .json ()
5569 assert data ["meta" ] == {"api-version" : API_VERSION , "_last-serial" : PYPI_SERIAL_CONSTANT }
56- assert data ["name" ] == "aiohttp "
70+ assert data ["name" ] == "shelf-reader "
5771 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
72+
73+ # Check data of a wheel
74+ file_whl = next (
75+ (i for i in data ["files" ] if i ["filename" ] == "shelf_reader-0.1-py2-none-any.whl" ), None
76+ )
77+ assert file_whl is not None , "wheel file not found"
78+ assert file_whl ["url" ]
79+ assert file_whl ["hashes" ] == {
80+ "sha256" : "2eceb1643c10c5e4a65970baf63bde43b79cbdac7de81dae853ce47ab05197e9"
81+ }
82+ assert file_whl ["requires-python" ] is None
83+ # assert file_whl["data-dist-info-metadata"] == {
84+ # "sha256": "ed333f0db05d77e933a157b7225b403ada9a2f93318d77b41b662eba78bac350"
85+ # }
86+
87+ # Check data of a tarball
88+ file_tar = next ((i for i in data ["files" ] if i ["filename" ] == "shelf-reader-0.1.tar.gz" ), None )
89+ assert file_tar is not None , "tar file not found"
90+ assert file_tar ["url" ]
91+ assert file_tar ["hashes" ] == {
92+ "sha256" : "04cfd8bb4f843e35d51bfdef2035109bdea831b55a57c3e6a154d14be116398c"
93+ }
94+ assert file_tar ["requires-python" ] is None
95+ assert file_tar ["data-dist-info-metadata" ] is False
6796
6897
6998@pytest .mark .parallel
0 commit comments