launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25053
[Merge] ~cjwatson/launchpad:testfix-object-lookup-redirection into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:testfix-object-lookup-redirection into launchpad:master.
Commit message:
Fix a couple more test regressions from RedirectionView changes
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/387696
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:testfix-object-lookup-redirection into launchpad:master.
diff --git a/lib/lp/registry/browser/tests/test_person.py b/lib/lp/registry/browser/tests/test_person.py
index cc35863..208e6bf 100644
--- a/lib/lp/registry/browser/tests/test_person.py
+++ b/lib/lp/registry/browser/tests/test_person.py
@@ -13,6 +13,7 @@ import re
from textwrap import dedent
from fixtures import FakeLogger
+from six.moves.urllib.parse import urljoin
import soupmatchers
from storm.store import Store
from testtools.matchers import (
@@ -70,6 +71,7 @@ from lp.services.webapp.escaping import html_escape
from lp.services.webapp.interfaces import ILaunchBag
from lp.services.webapp.publisher import RedirectionView
from lp.services.webapp.servers import LaunchpadTestRequest
+from lp.services.webapp.vhosts import allvhosts
from lp.soyuz.enums import (
ArchivePurpose,
ArchiveStatus,
@@ -117,7 +119,9 @@ class TestPersonNavigation(TestCaseWithFactory):
def assertRedirect(self, path, redirect):
view = test_traverse(path)[1]
self.assertIsInstance(view, RedirectionView)
- self.assertEqual(':/' + redirect, removeSecurityProxy(view).target)
+ self.assertEqual(
+ urljoin(allvhosts.configs['mainsite'].rooturl, redirect),
+ removeSecurityProxy(view).target)
def test_traverse_archive_distroful(self):
archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA)
diff --git a/lib/lp/services/webapp/publisher.py b/lib/lp/services/webapp/publisher.py
index 7a49017..055a765 100644
--- a/lib/lp/services/webapp/publisher.py
+++ b/lib/lp/services/webapp/publisher.py
@@ -41,6 +41,7 @@ from lazr.restful.tales import WebLayerAPI
from lazr.restful.utils import get_current_browser_request
import simplejson
from six.moves import http_client
+from six.moves.urllib.parse import urlparse
from zope.app.publisher.xmlrpc import IMethodPublisher
from zope.component import (
getUtility,
@@ -1126,6 +1127,10 @@ class RedirectionView(URLDereferencingMixin):
raise AttributeError(
"RedirectionView.context is only supported for webservice "
"requests.")
+ if urlparse(self.target).query:
+ raise AttributeError(
+ "RedirectionView.context is not supported for URLs with "
+ "query strings.")
return self.dereference_url_as_object(self.target)
diff --git a/lib/lp/testing/publication.py b/lib/lp/testing/publication.py
index 7f8ee3a..af1d12e 100644
--- a/lib/lp/testing/publication.py
+++ b/lib/lp/testing/publication.py
@@ -14,7 +14,10 @@ __all__ = [
from cStringIO import StringIO
-from six.moves.urllib_parse import unquote
+from six.moves.urllib_parse import (
+ unquote,
+ urljoin,
+ )
from zope.app.publication.requestpublicationregistry import factoryRegistry
from zope.authentication.interfaces import IUnauthenticatedPrincipal
from zope.component import (
@@ -34,6 +37,7 @@ from lp.services.webapp.interaction import (
)
from lp.services.webapp.interfaces import IOpenLaunchBag
from lp.services.webapp.servers import ProtocolErrorPublication
+from lp.services.webapp.vhosts import allvhosts
# Defines an helper function that returns the appropriate
@@ -96,6 +100,9 @@ def test_traverse(url):
transaction.
"""
url_parts = urlsplit(url)
+ if not url_parts[0]:
+ url_parts = urlsplit(
+ urljoin(allvhosts.configs['mainsite'].rooturl, url))
server_url = '://'.join(url_parts[0:2])
path_info = url_parts[2]
request, publication = get_request_and_publication(