Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 409 status code support to --skip-existing #162

Merged
merged 1 commit into from
Jan 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Rodrigue Cloutier <[email protected]>
Tyrel Souza <[email protected]> (https://tyrelsouza.com)
Adam Talsma <[email protected]>
Jens Diemer <[email protected]> (http://jensdiemer.de/)
Andrew Watts <[email protected]>
13 changes: 13 additions & 0 deletions tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ def test_skip_existing_skips_files_already_on_PyPI(monkeypatch):
package=pkg) is True


def test_skip_existing_skips_files_already_on_pypiserver(monkeypatch):
# pypiserver (https://pypi.python.org/pypi/pypiserver) responds with 409
response = pretend.stub(
status_code=409,
reason='A file named "twine-1.5.0-py2.py3-none-any.whl" already '
'exists for twine-1.5.0.')

pkg = package.PackageFile.from_filename(WHEEL_FIXTURE, None)
assert upload.skip_upload(response=response,
skip_existing=True,
package=pkg) is True


def test_skip_upload_respects_skip_existing(monkeypatch):
response = pretend.stub(
status_code=400,
Expand Down
2 changes: 1 addition & 1 deletion twine/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def find_dists(dists):
def skip_upload(response, skip_existing, package):
filename = package.basefilename
msg = 'A file named "{0}" already exists for'.format(filename)
return (response.status_code == 400 and
return (response.status_code in [400, 409] and
response.reason.startswith(msg) and
skip_existing)

Expand Down