Example #1
0
 def test_url_unicode(self):
     """
     If url is unicode, it is encoded as utf-8 before appending
     """
     request_ = add_bind_root('http://example.com', request)
     self.assertEqual(request_("get", u"foo\u0100").intent.url,
                      "http://example.com/foo\xc4\x80")
Example #2
0
 def test_bind_root_does_not_quote(self):
     """
     Appending URL is not quoted
     """
     request_ = add_bind_root("http://slashdot.org", request)
     self.assertEqual(request_("get", "foo~").intent.url,
                      "http://slashdot.org/foo~")
Example #3
0
 def test_root_unicode(self):
     """
     If root is unicode, it is encoded as ascii before appending
     """
     request_ = add_bind_root(u'http://example.com', request)
     self.assertEqual(request_("get", "foo").intent.url,
                      "http://example.com/foo")
Example #4
0
 def test_root_unicode(self):
     """
     If root is unicode, it is encoded as ascii before appending
     """
     request_ = add_bind_root(u'http://example.com', request)
     self.assertEqual(
         request_("get", "foo").intent.url, "http://example.com/foo")
Example #5
0
 def test_bind_root_does_not_quote(self):
     """
     Appending URL is not quoted
     """
     request_ = add_bind_root("http://slashdot.org", request)
     self.assertEqual(
         request_("get", "foo~").intent.url, "http://slashdot.org/foo~")
Example #6
0
 def test_bind_root_no_slashes(self):
     """
     Root URLs without a trailing slash will have one inserted
     automatically.
     """
     request_ = add_bind_root("http://slashdot.org", request)
     self.assertEqual(request_("get", "foo").intent.url,
                      "http://slashdot.org/foo")
Example #7
0
 def test_bind_root(self):
     """
     :func:`add_bind_root` decorates a request function to append any
     passed URL paths onto the root URL.
     """
     request_ = add_bind_root("http://slashdot.org/", request)
     self.assertEqual(request_("get", "foo").intent.url,
                      "http://slashdot.org/foo")
Example #8
0
 def test_url_unicode(self):
     """
     If url is unicode, it is encoded as utf-8 before appending
     """
     request_ = add_bind_root('http://example.com', request)
     self.assertEqual(
         request_("get", u"foo\u0100").intent.url,
         "http://example.com/foo\xc4\x80")
Example #9
0
 def test_bind_root_no_slashes(self):
     """
     Root URLs without a trailing slash will have one inserted
     automatically.
     """
     request_ = add_bind_root("http://slashdot.org", request)
     self.assertEqual(
         request_("get", "foo").intent.url, "http://slashdot.org/foo")
Example #10
0
 def test_bind_root(self):
     """
     :func:`add_bind_root` decorates a request function to append any
     passed URL paths onto the root URL.
     """
     request_ = add_bind_root("http://slashdot.org/", request)
     self.assertEqual(
         request_("get", "foo").intent.url, "http://slashdot.org/foo")
Example #11
0
 def service_request(*args, **kwargs):
     """
     Perform an HTTP request similar to the request from
     :func:`get_request_func`, with the additional feature of being bound to
     a specific Rackspace/OpenStack service, so that the path can be
     relative to the service endpoint.
     """
     endpoint = public_endpoint_url(catalog, service_name, region)
     bound_request = add_bind_root(endpoint, request_func)
     return bound_request(*args, **kwargs)
Example #12
0
 def service_request(*args, **kwargs):
     """
     Perform an HTTP request similar to the request from
     :func:`get_request_func`, with the additional feature of being bound to
     a specific Rackspace/OpenStack service, so that the path can be
     relative to the service endpoint.
     """
     endpoint = public_endpoint_url(catalog, service_name, region)
     bound_request = add_bind_root(endpoint, request_func)
     return bound_request(*args, **kwargs)
Example #13
0
    def got_auth((token, catalog)):
        request_ = add_headers(otter_headers(token), request)
        request_ = add_effect_on_response(invalidate_eff, service_request.reauth_codes, request_)
        request_ = add_json_request_data(request_)
        if "url" in service_config:
            request_ = add_bind_root(service_config["url"], request_)
        else:
            request_ = add_bind_service(catalog, service_name, region, log, request_)
        request_ = add_error_handling(service_request.success_pred, request_)
        if service_request.json_response:
            request_ = add_json_response(request_)

        return request_(
            service_request.method,
            service_request.url,
            headers=service_request.headers,
            data=service_request.data,
            params=service_request.params,
            log=log,
        )
Example #14
0
    def got_auth((token, catalog)):
        request_ = add_headers(otter_headers(token), request)
        request_ = add_effect_on_response(invalidate_eff,
                                          service_request.reauth_codes,
                                          request_)
        request_ = add_json_request_data(request_)
        if 'url' in service_config:
            request_ = add_bind_root(service_config['url'], request_)
        else:
            request_ = add_bind_service(catalog, service_name, region, log,
                                        request_)
        request_ = add_error_handling(service_request.success_pred, request_)
        if service_request.json_response:
            request_ = add_json_response(request_)

        return request_(service_request.method,
                        service_request.url,
                        headers=service_request.headers,
                        data=service_request.data,
                        params=service_request.params,
                        log=log)