Skip to content

Commit

Permalink
Fix one more test that decided to fail
Browse files Browse the repository at this point in the history
I changed tested content-type to the more appropriate for .zip
Twine sends application/octet-stream.
  • Loading branch information
abitrolly committed Sep 2, 2021
1 parent f92cf51 commit 9e3c81b
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions tests/unit/forklift/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2622,7 +2622,7 @@ def test_upload_succeeds_with_wheel(
"content": pretend.stub(
filename=filename,
file=io.BytesIO(filebody),
type="application/tar",
type="application/octet-stream",
),
}
)
Expand Down Expand Up @@ -2742,6 +2742,8 @@ def test_upload_succeeds_with_wheel_after_sdist(
RoleFactory.create(user=user, project=project)

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

db_request.user = user
db_request.user_agent = "warehouse-tests/6.6.6"
Expand All @@ -2752,19 +2754,22 @@ def test_upload_succeeds_with_wheel_after_sdist(
"version": release.version,
"filetype": "bdist_wheel",
"pyversion": "cp34",
"md5_digest": "335c476dc930b959dda9ec82bd65ef19",
"md5_digest": hashlib.md5(filebody).hexdigest(),
"content": pretend.stub(
filename=filename,
file=io.BytesIO(b"A fake file."),
type="application/tar",
file=io.BytesIO(filebody),
type="application/zip",
),
}
)

@pretend.call_recorder
def storage_service_store(path, file_path, *, meta):
with open(file_path, "rb") as fp:
assert fp.read() == b"A fake file."
if file_path.endswith(".metadata"):
assert fp.read() == b"Fake metadata"
else:
assert fp.read() == filebody

storage_service = pretend.stub(store=storage_service_store)
db_request.find_service = pretend.call_recorder(
Expand All @@ -2787,9 +2792,9 @@ def storage_service_store(path, file_path, *, meta):
pretend.call(
"/".join(
[
"4e",
"6e",
"fa4c0ee2bbad071b4f5b5ea68f1aea89fa716e7754eb13e2314d45a5916e",
file_storage_hash[:2],
file_storage_hash[2:4],
file_storage_hash[4:],
filename,
]
),
Expand All @@ -2800,6 +2805,23 @@ def storage_service_store(path, file_path, *, meta):
"package-type": "bdist_wheel",
"python-version": "cp34",
},
),
pretend.call(
"/".join(
[
file_storage_hash[:2],
file_storage_hash[2:4],
file_storage_hash[4:],
filename + '.metadata',
]
),
mock.ANY,
meta={
"project": project.normalized_name,
"version": release.version,
"package-type": "bdist_wheel",
"python-version": "cp34",
},
)
]

Expand Down

0 comments on commit 9e3c81b

Please sign in to comment.