@mock.patch.object(resource_objects.Resource, 'get_all_by_stack')
def test_iter_resources_with_filters(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 = mock.MagicMock()
    mock_rsc.name = 'A'
    mock_rsc.current_template_id = self.stack.t.id
    mock_db_call.return_value = {'A': mock_rsc}
    all_resources = list(self.stack.iter_resources(filters=dict(name=['A'])))
    mock_db_call.assert_has_calls([mock.call(self.ctx, self.stack.id, dict(name=['A'])), mock.call(self.ctx, self.stack.id)])
    self.assertEqual(1, len(all_resources))
    self.assertEqual('A', all_resources[0].name)
@mock.patch.object(resource_objects.Resource, 'get_all_by_stack')
def test_iter_resources_with_filters(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 = mock.MagicMock()
    mock_rsc.name = 'A'
    mock_rsc.current_template_id = self.stack.t.id
    mock_db_call.return_value = {'A': mock_rsc}
    all_resources = list(self.stack.iter_resources(filters=dict(name=['A'])))
    mock_db_call.assert_has_calls([mock.call(self.ctx, self.stack.id, dict(name=['A'])), mock.call(self.ctx, self.stack.id)])
    self.assertEqual(1, len(all_resources))
    self.assertEqual('A', all_resources[0].name)