Skip to content

Commit db17c85

Browse files
committed
Fix one more test that decided to fail
I changed tested content-type to the more appropriate for .zip Twine sends application/octet-stream.
1 parent a2e9a50 commit db17c85

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

tests/unit/forklift/test_legacy.py

+30-8
Original file line numberDiff line numberDiff line change
@@ -2622,7 +2622,7 @@ def test_upload_succeeds_with_wheel(
26222622
"content": pretend.stub(
26232623
filename=filename,
26242624
file=io.BytesIO(filebody),
2625-
type="application/tar",
2625+
type="application/octet-stream",
26262626
),
26272627
}
26282628
)
@@ -2742,6 +2742,8 @@ def test_upload_succeeds_with_wheel_after_sdist(
27422742
RoleFactory.create(user=user, project=project)
27432743

27442744
filename = "{}-{}-cp34-none-any.whl".format(project.name, release.version)
2745+
filebody = _get_whl_testdata(project.name)
2746+
file_storage_hash = _storage_hash(filebody)
27452747

27462748
db_request.user = user
27472749
db_request.user_agent = "warehouse-tests/6.6.6"
@@ -2752,19 +2754,22 @@ def test_upload_succeeds_with_wheel_after_sdist(
27522754
"version": release.version,
27532755
"filetype": "bdist_wheel",
27542756
"pyversion": "cp34",
2755-
"md5_digest": "335c476dc930b959dda9ec82bd65ef19",
2757+
"md5_digest": hashlib.md5(filebody).hexdigest(),
27562758
"content": pretend.stub(
27572759
filename=filename,
2758-
file=io.BytesIO(b"A fake file."),
2759-
type="application/tar",
2760+
file=io.BytesIO(filebody),
2761+
type="application/zip",
27602762
),
27612763
}
27622764
)
27632765

27642766
@pretend.call_recorder
27652767
def storage_service_store(path, file_path, *, meta):
27662768
with open(file_path, "rb") as fp:
2767-
assert fp.read() == b"A fake file."
2769+
if file_path.endswith(".metadata"):
2770+
assert fp.read() == b"Fake metadata"
2771+
else:
2772+
assert fp.read() == filebody
27682773

27692774
storage_service = pretend.stub(store=storage_service_store)
27702775
db_request.find_service = pretend.call_recorder(
@@ -2787,9 +2792,9 @@ def storage_service_store(path, file_path, *, meta):
27872792
pretend.call(
27882793
"/".join(
27892794
[
2790-
"4e",
2791-
"6e",
2792-
"fa4c0ee2bbad071b4f5b5ea68f1aea89fa716e7754eb13e2314d45a5916e",
2795+
file_storage_hash[:2],
2796+
file_storage_hash[2:4],
2797+
file_storage_hash[4:],
27932798
filename,
27942799
]
27952800
),
@@ -2800,6 +2805,23 @@ def storage_service_store(path, file_path, *, meta):
28002805
"package-type": "bdist_wheel",
28012806
"python-version": "cp34",
28022807
},
2808+
),
2809+
pretend.call(
2810+
"/".join(
2811+
[
2812+
file_storage_hash[:2],
2813+
file_storage_hash[2:4],
2814+
file_storage_hash[4:],
2815+
filename + '.metadata',
2816+
]
2817+
),
2818+
mock.ANY,
2819+
meta={
2820+
"project": project.normalized_name,
2821+
"version": release.version,
2822+
"package-type": "bdist_wheel",
2823+
"python-version": "cp34",
2824+
},
28032825
)
28042826
]
28052827

0 commit comments

Comments
 (0)