}]
        },
        "RoleId": "AROAJG7O4RNNSRINMF6DI",
        "CreateDate": "2014-05-01T23:47:14.552Z",
        "RoleName": EC2_ROLE_NAME,
        "Path": "/",
        "Arn": "arn:aws:iam::176430881729:role/" + EC2_ROLE_NAME
    }
}

CONSTRUCTED_RESULT_OUTPUT = [{
    "Role": CREATE_EC2_ROLE_RESULT['Role'],
    "RolePolicy": EC2_ROLE_POLICY
}]

http_response = AWSResponse(None, 200, {}, None)

CN_EC2_ROLE_ARN = ('arn:aws-cn:iam::aws:policy/service-role/'
                   'AmazonElasticMapReduceforEC2Role')
US_GOV_EC2_ROLE_ARN = ('arn:aws-us-gov:iam::aws:policy/service-role/'
                       'AmazonElasticMapReduceforEC2Role')

EC2_ROLE_ARN = ('arn:aws:iam::aws:policy/service-role/'
                'AmazonElasticMapReduceforEC2Role')

CN_EMR_ROLE_ARN = ('arn:aws-cn:iam::aws:policy/service-role/'
                   'AmazonElasticMapReduceRole')

US_GOV_EMR_ROLE_ARN = ('arn:aws-us-gov:iam::aws:policy/'
                       'service-role/AmazonElasticMapReduceRole')
Example #2
0
 def setUp(self):
     self.response = AWSResponse('http://url.com', 200, HeadersDict(), None)
     self.response.raw = Mock()
 def _response_func(*args, **kwargs):
     return AWSResponse("http://127.0.0.1", 200, {}, "{}"), response
    def add_client_error(self,
                         method,
                         service_error_code='',
                         service_message='',
                         http_status_code=400,
                         service_error_meta=None,
                         expected_params=None,
                         response_meta=None):
        """
        Adds a ``ClientError`` to the response queue.

        :param method: The name of the service method to return the error on.
        :type method: str

        :param service_error_code: The service error code to return,
                                   e.g. ``NoSuchBucket``
        :type service_error_code: str

        :param service_message: The service message to return, e.g.
                        'The specified bucket does not exist.'
        :type service_message: str

        :param http_status_code: The HTTP status code to return, e.g. 404, etc
        :type http_status_code: int

        :param service_error_meta: Additional keys to be added to the
            service Error
        :type service_error_meta: dict

        :param expected_params: A dictionary of the expected parameters to
            be called for the provided service response. The parameters match
            the names of keyword arguments passed to that client call. If
            any of the parameters differ a ``StubResponseError`` is thrown.
            You can use stub.ANY to indicate a particular parameter to ignore
            in validation.

        :param response_meta: Additional keys to be added to the
            response's ResponseMetadata
        :type response_meta: dict

        """
        http_response = AWSResponse(None, http_status_code, {}, None)

        # We don't look to the model to build this because the caller would
        # need to know the details of what the HTTP body would need to
        # look like.
        parsed_response = {
            'ResponseMetadata': {
                'HTTPStatusCode': http_status_code
            },
            'Error': {
                'Message': service_message,
                'Code': service_error_code
            }
        }

        if service_error_meta is not None:
            parsed_response['Error'].update(service_error_meta)

        if response_meta is not None:
            parsed_response['ResponseMetadata'].update(response_meta)

        operation_name = self.client.meta.method_to_api_mapping.get(method)
        # Note that we do not allow for expected_params while
        # adding errors into the queue yet.
        response = {
            'operation_name': operation_name,
            'response': (http_response, parsed_response),
            'expected_params': expected_params,
        }
        self._queue.append(response)