def test_delete_percolate_queries(self):
"""Test that we delete the percolate query from the index"""
query = {"query": {"match": {"profile.first_name": "here"}}}
with patch('search.signals.transaction', on_commit=lambda callback: callback()):
percolate_query = PercolateQueryFactory.create(query=query, original_query="original")
assert es.get_percolate_query(percolate_query.id) == {
'_id': str(percolate_query.id),
'_index': es.get_default_backing_index(),
'_source': query,
'_type': PERCOLATE_DOC_TYPE,
'_version': 1,
'found': True,
}
delete_percolate_query(percolate_query.id)
with self.assertRaises(NotFoundError):
es.get_percolate_query(percolate_query.id)
# If we delete it again there should be no exception
delete_percolate_query(percolate_query.id)
with self.assertRaises(NotFoundError):
es.get_percolate_query(percolate_query.id)
评论列表
文章目录