@pytest.mark.parametrize('es_search_fields, query_params, expected', [(('first_name',), {'search': 'Zofia'}, [1]), (('first_name', 'last_name', 'city'), {'search': 'Zofia'}, [1]), (('first_name', 'last_name', 'city'), {'search': 'Zofia Rome'}, [4, 7]), ('description', {'search': 'information'}, [2]), ('description', {'search': 'Ford Prefect'}, [2, 8, 10, 5, 6, 12]), ('description', {'search': 'Earth'}, [5, 3, 14]), ('description', {'search': 'The Hitchhiker’s Guide'}, [8])])
def test_filter_search(self, search, es_search_fields, query_params, expected):
    view = self.create_view(es_search_fields)
    request = rf.get('/test/')
    request.query_params = query_params
    search = self.backend.filter_search(request, search, view)
    result = get_search_ids(search)
    assert (result == expected)
@pytest.mark.parametrize('es_search_fields, query_params, expected', [(('first_name',), {'search': 'Zofia'}, [1]), (('first_name', 'last_name', 'city'), {'search': 'Zofia'}, [1]), (('first_name', 'last_name', 'city'), {'search': 'Zofia Rome'}, [4, 7]), ('description', {'search': 'information'}, [2]), ('description', {'search': 'Ford Prefect'}, [2, 8, 10, 5, 6, 12]), ('description', {'search': 'Earth'}, [5, 3, 14]), ('description', {'search': 'The Hitchhiker’s Guide'}, [8])])
def test_filter_search(self, search, es_search_fields, query_params, expected):
    view = self.create_view(es_search_fields)
    request = rf.get('/test/')
    request.query_params = query_params
    search = self.backend.filter_search(request, search, view)
    result = get_search_ids(search)
    assert (result == expected)