Skip to content

Missing email url #3533

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

Merged
merged 4 commits into from
Apr 3, 2018
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
12 changes: 10 additions & 2 deletions tests/unit/forklift/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2746,16 +2746,24 @@ def test_upload_requires_verified_email(self, pyramid_config, db_request,
resp = legacy.file_upload(db_request)
assert resp.status_code == 200
else:
db_request.route_url = pretend.call_recorder(
lambda route, **kw: "/the/help/url/"
)

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

resp = excinfo.value

assert db_request.route_url.calls == [
pretend.call('help', _anchor='verified-email')
]
assert resp.status_code == 400
assert resp.status == (
("400 User {!r} has no verified email "
"addresses, please verify at least one "
"address before registering a new project "
"on PyPI. See "
"https://pypi.org/help/#verified-email "
"on PyPI. See /the/help/url/ "
"for more information.").format(user.username)
)

Expand Down
13 changes: 8 additions & 5 deletions warehouse/forklift/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,11 +823,14 @@ def file_upload(request):
if not any(email.verified for email in request.user.emails):
raise _exc_with_message(
HTTPBadRequest,
("User {!r} has no verified email addresses, please verify "
"at least one address before registering a new project on "
"PyPI. See https://pypi.org/help/#verified-email "
"for more information.")
.format(request.user.username),
("User {!r} has no verified email addresses, "
"please verify at least one address before registering "
"a new project on PyPI. See {projecthelp} "
"for more information.").format(
request.user.username,
projecthelp=request.route_url(
'help', _anchor='verified-email'
)),
) from None

# Before we create the project, we're going to check our blacklist to
Expand Down