Repository: pypi/warehouse

Issue:
Make error message (for missing verified email) work with Test PyPI
Right now, when someone tries to upload a package to PyPI but does not have a verified email address on file, the error message we send them includes -- hardcoded -- the URL https://pypi.org. Instead, we should use Pyramid's URL routing to refer to the URL of the PyPI in question, thus ensuring that we send error messages that, as appropriate, refer to pypi.org, test.pypi.org, or any other future PyPI.

To fix this, look at `warehouse/forklift/legacy.py` and `tests/unit/forklift/test_legacy.py` (the test is `test_upload_requires_verified_email`), and make changes similar to the changes I made in #3183. If you're used to string substitution/string formatting in Python, this should be a pretty approachable first Warehouse issue.

---

**Good First Issue**: This issue is good for first time contributors. If you've already contributed to Warehouse, please work on [another issue without this label](https://github.com/pypa/warehouse/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+-label%3A%22good+first+issue%22) instead. If there is not a corresponding pull request for this issue, it is up for grabs. For directions for getting set up, see our [Getting Started Guide](https://warehouse.pypa.io/development/getting-started/). If you are working on this issue and have questions, please feel free to ask them here, [`#pypa-dev` on Freenode](https://webchat.freenode.net/?channels=%23pypa-dev), or the [pypa-dev mailing list](https://groups.google.com/forum/#!forum/pypa-dev).



Discussion:
I'm willing to work on this one. I'll let you know about the further progress @brainwane 
Sounds good. @nitinprakash96 you go ahead and work on this one, and @saxenanurag can concentrate on #3185 instead. :)

Resolving patch:
diff --git a/warehouse/forklift/legacy.py b/warehouse/forklift/legacy.py
--- a/warehouse/forklift/legacy.py
+++ b/warehouse/forklift/legacy.py
@@ -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


Test patch:
diff --git a/tests/unit/forklift/test_legacy.py b/tests/unit/forklift/test_legacy.py
--- a/tests/unit/forklift/test_legacy.py
+++ b/tests/unit/forklift/test_legacy.py
@@ -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)
             )