Exemplo n.º 1
0
 def test_find_resource_no_expected_type_optional_not_present(self):
     test_value = 'test-value'
     target = stack_info.ResourceInfoList(MOCK_STACK_INFO)
     target.append(mock.MagicMock(test_attr='unexpected-1'))
     target.append(mock.MagicMock(test_attr='unexpected-2'))
     actual_resource = target._ResourceInfoList__find_resource(
         'test_attr', test_value, None, True)
     self.assertIsNone(actual_resource)
Exemplo n.º 2
0
 def test_find_resource_no_expected_type_not_optional_not_present(self):
     test_value = 'test-value'
     mock_stack_info = mock.MagicMock()
     mock_stack_info.stack_arn = MOCK_STACK_ARN
     target = stack_info.ResourceInfoList(mock_stack_info)
     target.append(mock.MagicMock(test_attr='unexpected-1'))
     target.append(mock.MagicMock(test_attr='unexpected-2'))
     with self.assertRaisesRegexp(RuntimeError, test_value):
         target._ResourceInfoList__find_resource('test_attr', test_value,
                                                 None, False)
Exemplo n.º 3
0
 def test_get_by_logical_id_default(self):
     expected_resource = 'test-resource'
     logical_id = 'test-id'
     with mock.patch(
             'resource_manager_common.stack_info.ResourceInfoList._ResourceInfoList__find_resource',
             return_value=expected_resource) as mock_find_resource:
         target = stack_info.ResourceInfoList(MOCK_STACK_INFO)
         actual_resource = target.get_by_logical_id(logical_id)
         self.assertIs(actual_resource, expected_resource)
         mock_find_resource.assert_called_once_with('logical_id',
                                                    logical_id, None, False)
Exemplo n.º 4
0
 def test_find_resource_expected_type_not_optional_present(self):
     test_value = 'test-value'
     expected_type = 'test-type'
     expected_resource = mock.MagicMock(test_attr=test_value,
                                        type=expected_type)
     target = stack_info.ResourceInfoList(MOCK_STACK_INFO)
     target.append(mock.MagicMock(test_attr='unexpected-1'))
     target.append(expected_resource)
     target.append(mock.MagicMock(test_attr='unexpected-2'))
     actual_resource = target._ResourceInfoList__find_resource(
         'test_attr', test_value, expected_type, False)
     self.assertIs(actual_resource, expected_resource)
Exemplo n.º 5
0
 def test_get_by_type(self):
     test_value = 'test-value'
     expected_type = 'test-type'
     expected_resource = mock.MagicMock(test_attr=test_value,
                                        type=expected_type)
     expected_list = [expected_resource]
     target = stack_info.ResourceInfoList(MOCK_STACK_INFO)
     target.append(
         mock.MagicMock(test_attr='unexpected-1', type='unexpected-type'))
     target.append(expected_resource)
     target.append(
         mock.MagicMock(test_attr='unexpected-2', type='unexpected-type'))
     actual_list = target.get_by_type(expected_type)
     self.assertItemsEqual(actual_list, expected_list)
Exemplo n.º 6
0
 def test_get_by_physical_id_with_args(self):
     expected_resource = 'test-resource'
     physical_id = 'test-id'
     expected_type = 'test-type'
     optional = True
     with mock.patch(
             'resource_manager_common.stack_info.ResourceInfoList._ResourceInfoList__find_resource',
             return_value=expected_resource) as mock_find_resource:
         target = stack_info.ResourceInfoList(MOCK_STACK_INFO)
         actual_resource = target.get_by_physical_id(
             physical_id, expected_type=expected_type, optional=optional)
         self.assertIs(actual_resource, expected_resource)
         mock_find_resource.assert_called_once_with('physical_id',
                                                    physical_id,
                                                    expected_type, optional)
Exemplo n.º 7
0
 def test_constructor(self):
     target = stack_info.ResourceInfoList(MOCK_STACK_INFO)
     self.assertIs(target.stack, MOCK_STACK_INFO)