コード例 #1
0
 def test_resources(self):
     mock_resource_summary_1 = make_random_resource_summary()
     mock_resource_summary_2 = make_random_resource_summary()
     mock_resource_summary_list = [
         mock_resource_summary_1, mock_resource_summary_2
     ]
     mock_response = make_list_stack_resources_response(
         mock_resource_summary_list)
     mock_resources = ['mock-resource-info-1', 'mock-resource-info-2']
     with mock_aws.patch_client(
             'cloudformation',
             'list_stack_resources',
             return_value=mock_response) as mock_list_stack_resources:
         with mock.patch('resource_manager_common.stack_info.ResourceInfo',
                         side_effect=mock_resources) as mock_ResourceInfo:
             target = stack_info.StackInfo(MOCK_STACK_ARN, MOCK_STACK_TYPE)
             actual_resources = target.resources
             actual_resources_2 = target.resources
             self.assertItemsEqual(actual_resources, mock_resources)
             self.assertIs(actual_resources, actual_resources_2)
             self.assertIs(actual_resources.stack, target)
             mock_list_stack_resources.assert_called_once_with(
                 StackName=MOCK_STACK_ARN)
             mock_ResourceInfo.assert_any_call(target,
                                               mock_resource_summary_1)
             mock_ResourceInfo.assert_any_call(target,
                                               mock_resource_summary_2)
コード例 #2
0
 def test_parameters(self):
     key1 = 'key1'
     value1 = 'value1'
     key2 = 'key2'
     value2 = 'value2'
     mock_parameters = [
         make_parameter(key1, value1),
         make_parameter(key2, value2)
     ]
     mock_stack_description = {"Parameters": mock_parameters}
     mock_parameters_dict = mock.MagicMock()
     with mock.patch(
             'resource_manager_common.stack_info.StackInfo.stack_description',
             new_callable=mock.PropertyMock,
             return_value=mock_stack_description):
         with mock.patch(
                 'resource_manager_common.stack_info.ParametersDict',
                 return_value=mock_parameters_dict) as mock_ParametersDict:
             target = stack_info.StackInfo(MOCK_STACK_ARN, MOCK_STACK_TYPE)
             actual_parameters = target.parameters
             actual_parameters_2 = target.parameters
             self.assertIs(actual_parameters, mock_parameters_dict)
             self.assertIs(actual_parameters_2, mock_parameters_dict)
             mock_ParametersDict.assert_called_once_with(MOCK_STACK_ARN)
             mock_parameters_dict.__setitem__.assert_any_call(key1, value1)
             mock_parameters_dict.__setitem__.assert_any_call(key2, value2)
コード例 #3
0
 def test_client_provided(self):
     expected_client = 'expected-client'
     target = stack_info.StackInfo(MOCK_STACK_ARN,
                                   MOCK_STACK_TYPE,
                                   client=expected_client)
     actual_client = target.client
     self.assertIs(actual_client, expected_client)
コード例 #4
0
 def test_client_created(self):
     with mock.patch('boto3.client') as mock_client_factory:
         target = stack_info.StackInfo(MOCK_STACK_ARN, MOCK_STACK_TYPE)
         actual_client = target.client
         actual_client_2 = target.client
         self.assertIsNotNone(actual_client)
         self.assertIs(actual_client, actual_client_2)
         mock_client_factory.assert_called_once_with(
             'cloudformation', region_name=MOCK_REGION)
コード例 #5
0
 def test_stack_description_loaded(self):
     mock_response = make_describe_stacks_response(MOCK_STACK_DESCRIPTION)
     with mock_aws.patch_client(
             'cloudformation', 'describe_stacks',
             return_value=mock_response) as mock_describe_stacks:
         target = stack_info.StackInfo(MOCK_STACK_ARN, MOCK_STACK_TYPE)
         actual_stack_description = target.stack_description
         actual_stack_description_2 = target.stack_description
         self.assertEquals(actual_stack_description, MOCK_STACK_DESCRIPTION)
         self.assertIs(actual_stack_description, actual_stack_description_2)
         mock_describe_stacks.assert_called_once_with(
             StackName=MOCK_STACK_ARN)
コード例 #6
0
 def test_stack_description_provided(self):
     target = stack_info.StackInfo(MOCK_STACK_ARN,
                                   MOCK_STACK_TYPE,
                                   stack_description=MOCK_STACK_DESCRIPTION)
     actual_stack_description = target.stack_description
     self.assertEquals(actual_stack_description, MOCK_STACK_DESCRIPTION)
コード例 #7
0
 def test_account_id(self):
     expected_account_id = MOCK_ACCOUNT_ID
     target = stack_info.StackInfo(MOCK_STACK_ARN, MOCK_STACK_TYPE)
     actual_account_id = target.account_id
     self.assertEquals(actual_account_id, expected_account_id)
コード例 #8
0
 def test_region(self):
     expected_region = MOCK_REGION
     target = stack_info.StackInfo(MOCK_STACK_ARN, MOCK_STACK_TYPE)
     actual_region = target.region
     self.assertEquals(actual_region, expected_region)
コード例 #9
0
 def test_stack_name(self):
     expected_stack_name = MOCK_STACK_NAME
     target = stack_info.StackInfo(MOCK_STACK_ARN, MOCK_STACK_TYPE)
     actual_stack_name = target.stack_name
     self.assertEquals(actual_stack_name, expected_stack_name)
コード例 #10
0
 def test_stack_type(self):
     expected_stack_type = 'stack-type'
     target = stack_info.StackInfo(MOCK_STACK_ARN, expected_stack_type)
     actual_stack_type = target.stack_type
     self.assertEquals(actual_stack_type, expected_stack_type)
コード例 #11
0
 def test_stack_arn(self):
     expected_stack_arn = 'stack-arn'
     target = stack_info.StackInfo(expected_stack_arn, MOCK_STACK_TYPE)
     actual_stack_arn = target.stack_arn
     self.assertEquals(actual_stack_arn, expected_stack_arn)