~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/_webservice.py

[r=gmb, leonardr][ui=none][bug=620458,
        629804] use LaunchpadWebServiceCaller to check the HTTP response in
        test_user_access_to_private_bug_attachment()

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
    version = version or Launchpad.DEFAULT_VERSION
146
146
    cache = tempfile.mkdtemp(prefix='launchpadlib-cache-')
147
147
    zope.testing.cleanup.addCleanUp(_clean_up_cache, (cache,))
148
 
    return TestLaunchpad(credentials, None, None, service_root=service_root,
149
 
                         version=version, cache=cache)
150
 
 
151
 
 
152
 
class TestLaunchpad(Launchpad):
153
 
    """A variant of the Launchpad service root class providing test helpers.
154
 
    """
155
 
 
156
 
    def rawGet(self, url, follow_redirects=None):
157
 
        """Return a the result of a GET request for the given URL.
158
 
 
159
 
        :param url: The URL of the request.
160
 
        :param follow_redirects: If None, keep the default behaviour.
161
 
            If True, follow redirect responses.
162
 
            If False, do not follow a redirect response but return the
163
 
            plain redirect.
164
 
 
165
 
        :return: The tuple (response, content)
166
 
        """
167
 
        default_redirect = self._browser._connection.follow_redirects
168
 
        if follow_redirects is not None:
169
 
            self._browser._connection.follow_redirects = follow_redirects
170
 
        response, content = self._browser.get(url, return_response=True)
171
 
        self._browser._connection.follow_redirects = default_redirect
172
 
        return response, content
 
148
    return Launchpad(credentials, None, None, service_root=service_root,
 
149
                     version=version, cache=cache)
173
150
 
174
151
 
175
152
class QueryCollector: