@mock.patch.object(resource_objects.Resource, 'get_all_by_stack')
def test_iter_resources(self, mock_db_call):
    tpl = {'HeatTemplateFormatVersion': '2012-12-12', 'Resources': {'A': {'Type': 'GenericResourceType'}, 'B': {'Type': 'GenericResourceType'}}}
    self.stack = stack.Stack(self.ctx, 'test_stack', template.Template(tpl), status_reason='blarg')
    self.stack.store()
    mock_rsc_a = mock.MagicMock(current_template_id=self.stack.t.id)
    mock_rsc_a.name = 'A'
    mock_rsc_b = mock.MagicMock(current_template_id=self.stack.t.id)
    mock_rsc_b.name = 'B'
    mock_db_call.return_value = {'A': mock_rsc_a, 'B': mock_rsc_b}
    all_resources = list(self.stack.iter_resources())
    mock_db_call.assert_called_once_with(self.ctx, self.stack.id)
    names = sorted([r.name for r in all_resources])
    self.assertEqual(['A', 'B'], names)
@mock.patch.object(resource_objects.Resource, 'get_all_by_stack')
def test_iter_resources(self, mock_db_call):
    tpl = {'HeatTemplateFormatVersion': '2012-12-12', 'Resources': {'A': {'Type': 'GenericResourceType'}, 'B': {'Type': 'GenericResourceType'}}}
    self.stack = stack.Stack(self.ctx, 'test_stack', template.Template(tpl), status_reason='blarg')
    self.stack.store()
    mock_rsc_a = mock.MagicMock(current_template_id=self.stack.t.id)
    mock_rsc_a.name = 'A'
    mock_rsc_b = mock.MagicMock(current_template_id=self.stack.t.id)
    mock_rsc_b.name = 'B'
    mock_db_call.return_value = {'A': mock_rsc_a, 'B': mock_rsc_b}
    all_resources = list(self.stack.iter_resources())
    mock_db_call.assert_called_once_with(self.ctx, self.stack.id)
    names = sorted([r.name for r in all_resources])
    self.assertEqual(['A', 'B'], names)