'FakeElasticsearch' object has no attribute 'indices'
armudgal opened this issue · 3 comments
armudgal commented
Hi there,
I just wanted to know whether ElasticMock supports 'indices' or not, and if not how can I mock the same, I will send a PR if I find a solution
adisunw commented
I ran into the same issue. It looks like there is a lot of missing elasticmock support (i'm running v7.0.2) and I ended up having to fork and fill in the gaps where it was missing. For the indices
problem you are facing, you can make a class property for the FakeElasticsearch
class like so
@property
def indices(self):
return Index()
and make a mocked Index class:
class Index:
def __init__(self):
pass
@staticmethod
def create(index: str, ignore: Union[int, List[int]]):
if index in FakeElasticsearch.documents_dict:
return
FakeElasticsearch.documents_dict[index] = list()
@staticmethod
def refresh(index: str):
pass
@staticmethod
def delete(index: str, ignore: Union[int, List[int]]):
if index in FakeElasticsearch.documents_dict:
del FakeElasticsearch.documents_dict[index]
@staticmethod
def exists(index: str):
return index in FakeElasticsearch.documents_dict
The Index
class is obviously incomplete, but it accomplishes my mocking tasks.