'Test that we don\'t call a filter when its
run_filter_for_index() method returns false'

def test_get_filtered_objects_for_index(self):

    filter_objs_initial = ['initial', 'filter1', 'objects1']
    filter_objs_second = ['second', 'filter2', 'objects2']
    spec_obj = objects.RequestSpec()
    def _fake_base_loader_init(*args, **kwargs):
        pass
    self.stub_out('nova.loadables.BaseLoader.__init__', _fake_base_loader_init)
    filt1_mock = mock.Mock(Filter1)
    filt1_mock.run_filter_for_index.return_value = True
    filt1_mock.filter_all.return_value = filter_objs_second
    filt2_mock = mock.Mock(Filter2)
    filt2_mock.run_filter_for_index.return_value = False
    filter_handler = filters.BaseFilterHandler(filters.BaseFilter)
    filter_mocks = [filt1_mock, filt2_mock]
    result = filter_handler.get_filtered_objects(filter_mocks, filter_objs_initial, spec_obj)
    self.assertEqual(filter_objs_second, result)
    filt1_mock.filter_all.assert_called_once_with(filter_objs_initial, spec_obj)
    filt2_mock.filter_all.assert_not_called()
