|
8 | 8 | PYTHON_EGG_FILENAME, |
9 | 9 | PYTHON_EGG_SHA256, |
10 | 10 | PYTHON_EGG_URL, |
| 11 | + PYTHON_SM_FIXTURE_CHECKSUMS, |
| 12 | + PYTHON_SM_FIXTURE_RELEASES, |
11 | 13 | PYTHON_SM_PROJECT_SPECIFIER, |
12 | 14 | PYTHON_WHEEL_FILENAME, |
13 | 15 | PYTHON_WHEEL_METADATA_SHA256, |
14 | 16 | PYTHON_WHEEL_SHA256, |
15 | 17 | PYTHON_WHEEL_URL, |
| 18 | + PYTHON_XS_FIXTURE_CHECKSUMS, |
16 | 19 | ) |
| 20 | +from pulp_python.tests.functional.utils import ensure_simple |
17 | 21 |
|
18 | 22 | API_VERSION = "1.1" |
19 | 23 |
|
|
22 | 26 | PYPI_SIMPLE_V1_JSON = "application/vnd.pypi.simple.v1+json" |
23 | 27 |
|
24 | 28 |
|
| 29 | +@pytest.mark.parallel |
| 30 | +def test_simple_html_index_api( |
| 31 | + python_remote_factory, python_repo_with_sync, python_distribution_factory |
| 32 | +): |
| 33 | + remote = python_remote_factory(includes=PYTHON_SM_PROJECT_SPECIFIER) |
| 34 | + repo = python_repo_with_sync(remote) |
| 35 | + distro = python_distribution_factory(repository=repo) |
| 36 | + |
| 37 | + url = urljoin(distro.base_url, "simple/") |
| 38 | + headers = {"Accept": PYPI_SIMPLE_V1_HTML} |
| 39 | + |
| 40 | + response = requests.get(url, headers=headers) |
| 41 | + assert response.headers["Content-Type"] == PYPI_SIMPLE_V1_HTML |
| 42 | + assert response.headers["X-PyPI-Last-Serial"] == str(PYPI_SERIAL_CONSTANT) |
| 43 | + |
| 44 | + proper, msgs = ensure_simple( |
| 45 | + url, PYTHON_SM_FIXTURE_RELEASES, sha_digests=PYTHON_SM_FIXTURE_CHECKSUMS |
| 46 | + ) |
| 47 | + assert proper, f"Simple API validation failed: {msgs}" |
| 48 | + |
| 49 | + |
| 50 | +def test_simple_html_detail_api( |
| 51 | + delete_orphans_pre, |
| 52 | + monitor_task, |
| 53 | + python_bindings, |
| 54 | + python_content_factory, |
| 55 | + python_distribution_factory, |
| 56 | + python_repo_factory, |
| 57 | +): |
| 58 | + content_1 = python_content_factory(PYTHON_WHEEL_FILENAME, url=PYTHON_WHEEL_URL) |
| 59 | + content_2 = python_content_factory(PYTHON_EGG_FILENAME, url=PYTHON_EGG_URL) |
| 60 | + body = {"add_content_units": [content_1.pulp_href, content_2.pulp_href]} |
| 61 | + |
| 62 | + repo = python_repo_factory() |
| 63 | + monitor_task(python_bindings.RepositoriesPythonApi.modify(repo.pulp_href, body).task) |
| 64 | + distro = python_distribution_factory(repository=repo) |
| 65 | + |
| 66 | + url = f'{urljoin(distro.base_url, "simple/")}shelf-reader' |
| 67 | + headers = {"Accept": PYPI_SIMPLE_V1_HTML} |
| 68 | + |
| 69 | + response = requests.get(url, headers=headers) |
| 70 | + assert response.headers["Content-Type"] == PYPI_SIMPLE_V1_HTML |
| 71 | + assert response.headers["X-PyPI-Last-Serial"] == str(PYPI_SERIAL_CONSTANT) |
| 72 | + |
| 73 | + proper, msgs = ensure_simple( |
| 74 | + urljoin(distro.base_url, "simple/"), |
| 75 | + {"shelf-reader": [PYTHON_WHEEL_FILENAME, PYTHON_EGG_FILENAME]}, |
| 76 | + sha_digests=PYTHON_XS_FIXTURE_CHECKSUMS, |
| 77 | + ) |
| 78 | + assert proper, f"Simple API validation failed: {msgs}" |
| 79 | + |
| 80 | + html_content = response.text |
| 81 | + assert f'data-dist-info-metadata="sha256={PYTHON_WHEEL_METADATA_SHA256}' in html_content |
| 82 | + |
| 83 | + |
25 | 84 | @pytest.mark.parallel |
26 | 85 | def test_simple_json_index_api( |
27 | 86 | python_remote_factory, python_repo_with_sync, python_distribution_factory |
|
0 commit comments