Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrutledge committed Jun 20, 2020
1 parent 9eb0a03 commit 7410b56
Showing 1 changed file with 36 additions and 24 deletions.
60 changes: 36 additions & 24 deletions tests/unit/forklift/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ def test_fails_disallow_new_upload(self, pyramid_config, pyramid_request):
assert resp.status_code == 403
assert resp.status == (
"403 New uploads are temporarily disabled. "
"See /the/help/url/ for details"
"See /the/help/url/ for more information."
)

@pytest.mark.parametrize("version", ["2", "3", "-1", "0", "dog", "cat"])
Expand Down Expand Up @@ -816,46 +816,52 @@ def test_fails_invalid_version(self, pyramid_config, pyramid_request, version):
"'' is an invalid value for Metadata-Version. "
"Error: This field is required. "
"See "
"https://packaging.python.org/specifications/core-metadata",
"https://packaging.python.org/specifications/core-metadata"
" for more information.",
),
(
{"metadata_version": "-1"},
"'-1' is an invalid value for Metadata-Version. "
"Error: Use a known metadata version. "
"See "
"https://packaging.python.org/specifications/core-metadata",
"https://packaging.python.org/specifications/core-metadata"
" for more information.",
),
# name errors.
(
{"metadata_version": "1.2"},
"'' is an invalid value for Name. "
"Error: This field is required. "
"See "
"https://packaging.python.org/specifications/core-metadata",
"https://packaging.python.org/specifications/core-metadata"
" for more information.",
),
(
{"metadata_version": "1.2", "name": "foo-"},
"'foo-' is an invalid value for Name. "
"Error: Start and end with a letter or numeral containing "
"only ASCII numeric and '.', '_' and '-'. "
"See "
"https://packaging.python.org/specifications/core-metadata",
"https://packaging.python.org/specifications/core-metadata"
" for more information.",
),
# version errors.
(
{"metadata_version": "1.2", "name": "example"},
"'' is an invalid value for Version. "
"Error: This field is required. "
"See "
"https://packaging.python.org/specifications/core-metadata",
"https://packaging.python.org/specifications/core-metadata"
" for more information.",
),
(
{"metadata_version": "1.2", "name": "example", "version": "dog"},
"'dog' is an invalid value for Version. "
"Error: Start and end with a letter or numeral "
"containing only ASCII numeric and '.', '_' and '-'. "
"See "
"https://packaging.python.org/specifications/core-metadata",
"https://packaging.python.org/specifications/core-metadata"
" for more information.",
),
# filetype/pyversion errors.
(
Expand Down Expand Up @@ -931,7 +937,8 @@ def test_fails_invalid_version(self, pyramid_config, pyramid_request, version):
"'" + "A" * 513 + "' is an invalid value for Summary. "
"Error: Field cannot be longer than 512 characters. "
"See "
"https://packaging.python.org/specifications/core-metadata",
"https://packaging.python.org/specifications/core-metadata"
" for more information.",
),
(
{
Expand All @@ -942,12 +949,11 @@ def test_fails_invalid_version(self, pyramid_config, pyramid_request, version):
"md5_digest": "a fake md5 digest",
"summary": "A\nB",
},
(
"{!r} is an invalid value for Summary. ".format("A\nB")
+ "Error: Use a single line only. "
"See "
"https://packaging.python.org/specifications/core-metadata"
),
"{!r} is an invalid value for Summary. ".format("A\nB")
+ "Error: Use a single line only. "
"See "
"https://packaging.python.org/specifications/core-metadata"
" for more information.",
),
# classifiers are a FieldStorage
(
Expand Down Expand Up @@ -1194,7 +1200,7 @@ def test_fails_with_admin_flag_set(self, pyramid_config, db_request):
"403 New project registration temporarily "
"disabled. See "
"/the/help/url/ for "
"details"
"more information."
)

def test_upload_fails_without_file(self, pyramid_config, db_request):
Expand Down Expand Up @@ -1553,7 +1559,8 @@ def test_upload_fails_with_legacy_ext(self, pyramid_config, db_request):
assert resp.status_code == 400
assert resp.status == (
"400 Invalid file extension: Use .egg, .tar.gz, .whl or .zip "
"extension. (https://www.python.org/dev/peps/pep-0527)"
"extension. See https://www.python.org/dev/peps/pep-0527 "
"for more information."
)

def test_upload_fails_for_second_sdist(self, pyramid_config, db_request):
Expand Down Expand Up @@ -1877,7 +1884,7 @@ def test_upload_fails_with_too_large_file(self, pyramid_config, db_request):
assert resp.status_code == 400
assert resp.status == (
"400 File too large. Limit for project 'foobar' is 60 MB. "
"See /the/help/url/"
"See /the/help/url/ for more information."
)

def test_upload_fails_with_too_large_signature(self, pyramid_config, db_request):
Expand Down Expand Up @@ -1960,7 +1967,7 @@ def test_upload_fails_with_previously_used_filename(
assert resp.status == (
"400 This filename has already been used, use a "
"different version. "
"See /the/help/url/"
"See /the/help/url/ for more information."
)

def test_upload_noop_with_existing_filename_same_content(
Expand Down Expand Up @@ -2060,7 +2067,9 @@ def test_upload_fails_with_existing_filename_diff_content(

assert db_request.help_url.calls == [pretend.call(_anchor="file-name-reuse")]
assert resp.status_code == 400
assert resp.status == "400 File already exists. See /the/help/url/"
assert resp.status == (
"400 File already exists. See /the/help/url/ for more information."
)

def test_upload_fails_with_diff_filename_same_blake2(
self, pyramid_config, db_request
Expand Down Expand Up @@ -2115,7 +2124,9 @@ def test_upload_fails_with_diff_filename_same_blake2(

assert db_request.help_url.calls == [pretend.call(_anchor="file-name-reuse")]
assert resp.status_code == 400
assert resp.status == "400 File already exists. See /the/help/url/"
assert resp.status == (
"400 File already exists. See /the/help/url/ for more information."
)

def test_upload_fails_with_wrong_filename(self, pyramid_config, db_request):
pyramid_config.testing_securitypolicy(userid=1)
Expand Down Expand Up @@ -2191,7 +2202,8 @@ def test_upload_fails_with_invalid_extension(self, pyramid_config, db_request):
assert resp.status_code == 400
assert resp.status == (
"400 Invalid file extension: Use .egg, .tar.gz, .whl or .zip "
"extension. (https://www.python.org/dev/peps/pep-0527)"
"extension. See https://www.python.org/dev/peps/pep-0527 "
"for more information."
)

@pytest.mark.parametrize("character", ["/", "\\"])
Expand Down Expand Up @@ -3106,7 +3118,7 @@ def test_upload_requires_verified_email(
"400 User {!r} does not have a verified primary email "
"address. Please add a verified primary email before "
"attempting to upload to PyPI. See /the/help/url/ for "
"more information.for more information."
"more information."
).format(user.username)
)

Expand Down Expand Up @@ -3157,7 +3169,7 @@ def test_fails_in_read_only_mode(self, pyramid_request):
resp = excinfo.value

assert resp.status_code == 403
assert resp.status == ("403 Read-only mode: Uploads are temporarily disabled")
assert resp.status == ("403 Read-only mode: Uploads are temporarily disabled.")

def test_fails_without_user(self, pyramid_config, pyramid_request):
pyramid_request.flags = pretend.stub(enabled=lambda *a: False)
Expand All @@ -3172,7 +3184,7 @@ def test_fails_without_user(self, pyramid_config, pyramid_request):
assert resp.status_code == 403
assert resp.status == (
"403 Invalid or non-existent authentication information. "
"See /the/help/url/ for details"
"See /the/help/url/ for more information."
)


Expand Down

0 comments on commit 7410b56

Please sign in to comment.