def _base_test(self, expect_args, expect_kwargs):
        class FakeAPI(object):
            """Fake API and ensure request url is correct."""
            def json_request(self, *args, **kwargs):
                assert expect_args == args
                assert expect_kwargs['data'] == kwargs['data']
                return {}, {}

        manager = actions.ActionManager(FakeAPI())
        return manager
Exemple #2
0
 def __init__(self, *args, **kwargs):
     """Initialize a new client for the Heat v1 API."""
     self.http_client = http._construct_http_client(*args, **kwargs)
     self.stacks = stacks.StackManager(self.http_client)
     self.resources = resources.ResourceManager(self.http_client)
     self.resource_types = resource_types.ResourceTypeManager(
         self.http_client)
     self.events = events.EventManager(self.http_client)
     self.actions = actions.ActionManager(self.http_client)
     self.build_info = build_info.BuildInfoManager(self.http_client)
     self.software_deployments = \
         software_deployments.SoftwareDeploymentManager(
             self.http_client)
     self.software_configs = software_configs.SoftwareConfigManager(
         self.http_client)
Exemple #3
0
    def _base_test(self, expect_args, expect_kwargs):

        class FakeAPI(object):
            """Fake API and ensure request url is correct."""

            def json_request(self, *args, **kwargs):
                assert expect_args == args
                assert expect_kwargs['data'] == kwargs['data']
                return fakes.FakeHTTPResponse(
                    '200',
                    '',
                    {'content-type': 'application/json'},
                    {}), {}

            def raw_request(self, *args, **kwargs):
                assert expect_args == args
                return fakes.FakeHTTPResponse(
                    '200',
                    '',
                    {},
                    {})

            def head(self, url, **kwargs):
                resp, body = self.json_request("HEAD", url, **kwargs)
                return resp

            def get(self, url, **kwargs):
                resp, body = self.json_request("GET", url, **kwargs)
                return resp

            def post(self, url, **kwargs):
                resp, body = self.json_request("POST", url, **kwargs)
                return resp

            def put(self, url, **kwargs):
                resp, body = self.json_request("PUT", url, **kwargs)
                return resp

            def delete(self, url, **kwargs):
                resp, body = self.raw_request("DELETE", url, **kwargs)
                return resp

            def patch(self, url, **kwargs):
                resp, body = self.json_request("PATCH", url, **kwargs)
                return resp

        manager = actions.ActionManager(FakeAPI())
        return manager