Skip to content

Commit

Permalink
Merge pull request #162 from andrewwatts/skip-existing-on-409
Browse files Browse the repository at this point in the history
Add 409 status code support to --skip-existing
  • Loading branch information
sigmavirus24 committed Jan 28, 2016
2 parents 1147375 + 7f12732 commit cbcb5a4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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

0 comments on commit cbcb5a4

Please sign in to comment.