Skip to content

Commit f096946

Browse files
committed
Refactor code
1 parent feaff93 commit f096946

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

pulp_python/app/pypi/views.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,6 @@ def parse_package(release_package):
337337
@extend_schema(operation_id="pypi_simple_package_read", summary="Get package simple page")
338338
def retrieve(self, request, path, package):
339339
"""Retrieves the simple api html/json page for a package."""
340-
media_type = request.accepted_renderer.media_type
341-
342340
repo_ver, content = self.get_rvc()
343341
# Should I redirect if the normalized name is different?
344342
normalized = canonicalize_name(package)

pulp_python/tests/functional/api/test_pypi_apis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from urllib.parse import urljoin
66

77
from pulp_python.tests.functional.constants import (
8+
PYPI_SERIAL_CONSTANT,
89
PYTHON_SM_PROJECT_SPECIFIER,
910
PYTHON_SM_FIXTURE_RELEASES,
1011
PYTHON_SM_FIXTURE_CHECKSUMS,
@@ -23,7 +24,6 @@
2324

2425

2526
PYPI_LAST_SERIAL = "X-PYPI-LAST-SERIAL"
26-
PYPI_SERIAL_CONSTANT = 1000000000
2727

2828

2929
@pytest.fixture

pulp_python/tests/functional/api/test_pypi_simple_json_api.py renamed to pulp_python/tests/functional/api/test_pypi_simple_api.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
import requests
55

66
from pulp_python.tests.functional.constants import (
7+
PYPI_SERIAL_CONSTANT,
78
PYTHON_EGG_FILENAME,
9+
PYTHON_EGG_SHA256,
810
PYTHON_EGG_URL,
911
PYTHON_SM_PROJECT_SPECIFIER,
1012
PYTHON_WHEEL_FILENAME,
13+
PYTHON_WHEEL_METADATA_SHA256,
14+
PYTHON_WHEEL_SHA256,
1115
PYTHON_WHEEL_URL,
1216
)
1317

1418
API_VERSION = "1.1"
15-
PYPI_SERIAL_CONSTANT = 1000000000
1619

1720
PYPI_TEXT_HTML = "text/html"
1821
PYPI_SIMPLE_V1_HTML = "application/vnd.pypi.simple.v1+html"
@@ -72,27 +75,19 @@ def test_simple_json_detail_api(
7275
assert data["versions"] == ["0.1"]
7376

7477
# Check data of a wheel
75-
file_whl = next(
76-
(i for i in data["files"] if i["filename"] == "shelf_reader-0.1-py2-none-any.whl"), None
77-
)
78+
file_whl = next((i for i in data["files"] if i["filename"] == PYTHON_WHEEL_FILENAME), None)
7879
assert file_whl is not None, "wheel file not found"
7980
assert file_whl["url"]
80-
assert file_whl["hashes"] == {
81-
"sha256": "2eceb1643c10c5e4a65970baf63bde43b79cbdac7de81dae853ce47ab05197e9"
82-
}
81+
assert file_whl["hashes"] == {"sha256": PYTHON_WHEEL_SHA256}
8382
assert file_whl["requires-python"] is None
84-
assert file_whl["data-dist-info-metadata"] == {
85-
"sha256": "ed333f0db05d77e933a157b7225b403ada9a2f93318d77b41b662eba78bac350"
86-
}
83+
assert file_whl["data-dist-info-metadata"] == {"sha256": PYTHON_WHEEL_METADATA_SHA256}
8784
assert file_whl["size"] == 22455
8885
assert file_whl["upload-time"] is not None
8986
# Check data of a tarball
90-
file_tar = next((i for i in data["files"] if i["filename"] == "shelf-reader-0.1.tar.gz"), None)
87+
file_tar = next((i for i in data["files"] if i["filename"] == PYTHON_EGG_FILENAME), None)
9188
assert file_tar is not None, "tar file not found"
9289
assert file_tar["url"]
93-
assert file_tar["hashes"] == {
94-
"sha256": "04cfd8bb4f843e35d51bfdef2035109bdea831b55a57c3e6a154d14be116398c"
95-
}
90+
assert file_tar["hashes"] == {"sha256": PYTHON_EGG_SHA256}
9691
assert file_tar["requires-python"] is None
9792
assert file_tar["data-dist-info-metadata"] is False
9893
assert file_tar["size"] == 19097

pulp_python/tests/functional/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@
147147
PYTHON_WHEEL_URL = urljoin(urljoin(PYTHON_FIXTURES_URL, "packages/"), PYTHON_WHEEL_FILENAME)
148148
PYTHON_WHEEL_SHA256 = "2eceb1643c10c5e4a65970baf63bde43b79cbdac7de81dae853ce47ab05197e9"
149149

150+
PYTHON_WHEEL_METADATA_SHA256 = "ed333f0db05d77e933a157b7225b403ada9a2f93318d77b41b662eba78bac350"
151+
150152
PYTHON_XS_FIXTURE_CHECKSUMS = {
151153
PYTHON_EGG_FILENAME: PYTHON_EGG_SHA256,
152154
PYTHON_WHEEL_FILENAME: PYTHON_WHEEL_SHA256,
@@ -350,3 +352,5 @@
350352
VULNERABILITY_REPORT_TEST_PACKAGES = [
351353
"django==5.2.1",
352354
]
355+
356+
PYPI_SERIAL_CONSTANT = 1000000000

0 commit comments

Comments
 (0)