Skip to content

Commit 9acd2cf

Browse files
committed
Add filesize limit help link to error message
1 parent cd7408d commit 9acd2cf

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

tests/unit/forklift/test_legacy.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1540,15 +1540,22 @@ def test_upload_fails_with_too_large_file(self, pyramid_config,
15401540
type="application/tar",
15411541
),
15421542
})
1543+
db_request.route_url = pretend.call_recorder(
1544+
lambda route, **kw: "/the/help/url/"
1545+
)
15431546

15441547
with pytest.raises(HTTPBadRequest) as excinfo:
15451548
legacy.file_upload(db_request)
15461549

15471550
resp = excinfo.value
15481551

1552+
assert db_request.route_url.calls == [
1553+
pretend.call('help', _anchor='file-size-limit')
1554+
]
15491555
assert resp.status_code == 400
15501556
assert resp.status == (
1551-
"400 File too large. Limit for project 'foobar' is 60MB"
1557+
"400 File too large. Limit for project 'foobar' is 60MB. "
1558+
"See /the/help/url/"
15521559
)
15531560

15541561
def test_upload_fails_with_too_large_signature(self, pyramid_config,

warehouse/forklift/legacy.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -993,10 +993,14 @@ def file_upload(request):
993993
raise _exc_with_message(
994994
HTTPBadRequest,
995995
"File too large. " +
996-
"Limit for project {name!r} is {limit}MB".format(
996+
"Limit for project {name!r} is {limit}MB. ".format(
997997
name=project.name,
998-
limit=file_size_limit // (1024 * 1024),
999-
))
998+
limit=file_size_limit // (1024 * 1024)) +
999+
"See " +
1000+
request.route_url(
1001+
'help', _anchor='file-size-limit'
1002+
),
1003+
)
10001004
fp.write(chunk)
10011005
for hasher in file_hashes.values():
10021006
hasher.update(chunk)

0 commit comments

Comments
 (0)