Beispiel #1
0
 def test_add_effect_on_response(self):
     """Test the decorator :func:`add_effect_on_response`."""
     badauth = stub_pure_response("badauth!", code=401)
     request_ = add_effect_on_response(
         self.invalidate_effect, (401,), stub_request(badauth))
     eff = request_('m', 'u')
     self.assertEqual(resolve_stubs(eff), badauth)
     self.assertEqual(self.invalidations, [True])
Beispiel #2
0
 def test_add_effect_on_response(self):
     """Test the decorator :func:`add_effect_on_response`."""
     badauth = stub_pure_response("badauth!", code=401)
     request_ = add_effect_on_response(self.invalidate_effect, (401, ),
                                       stub_request(badauth))
     eff = request_('m', 'u')
     self.assertEqual(resolve_stubs(eff), badauth)
     self.assertEqual(self.invalidations, [True])
Beispiel #3
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,
        )
Beispiel #4
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)