def cfn_mock(self): cf_mock = Mock() cf_connect_result = Mock(name='cf_connect') cf_mock.return_value = cf_connect_result stack = "cfn_mock-dev-12345678" example_return = { 'DeleteStackResponse': { 'ResponseMetadata': { 'RequestId': 'someuuid' } } } stack_mock = Mock(stack_name=stack) stack_mock.resource_status = 'CREATE_COMPLETE' mock_config = { 'delete_stack.return_value': example_return, 'create_stack.return_value': stack, 'describe_stacks.return_value': [stack_mock], 'stack_done.return_value': True, 'describe_stack_events.return_value': [stack_mock] } cf_connect_result.configure_mock(**mock_config) boto.cloudformation.connect_to_region = cf_mock cf = cloudformation.Cloudformation("profile_name") return cf
def __init__(self, aws_profile_name, aws_region_name='eu-west-1'): self.aws_profile_name = aws_profile_name self.aws_region_name = aws_region_name self.conn_ec2 = utils.connect_to_aws(boto.ec2, self) self.cfn = cloudformation.Cloudformation( aws_profile_name=aws_profile_name, aws_region_name=aws_region_name)