Skip to content

Commit

Permalink
Fix tests for es > 7
Browse files Browse the repository at this point in the history
  • Loading branch information
chesstrian committed Apr 25, 2020
1 parent e14d124 commit d6f58a3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion elasticmock/fake_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class FakeClusterClient(ClusterClient):
@query_params('level', 'local', 'master_timeout', 'timeout',
'wait_for_active_shards', 'wait_for_nodes',
'wait_for_relocating_shards', 'wait_for_status')
def health(self, index=None, params=None):
def health(self, index=None, params=None, headers=None):
return {
'cluster_name': 'testcluster',
'status': 'green',
Expand Down
24 changes: 12 additions & 12 deletions elasticmock/fake_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ def cluster(self):
return FakeClusterClient(self)

@query_params()
def ping(self, params=None):
def ping(self, params=None, headers=None):
return True

@query_params()
def info(self, params=None):
def info(self, params=None, headers=None):
return {
'status': 200,
'cluster_name': 'elasticmock',
Expand All @@ -57,7 +57,7 @@ def info(self, params=None):

@query_params('consistency', 'op_type', 'parent', 'refresh', 'replication',
'routing', 'timeout', 'timestamp', 'ttl', 'version', 'version_type')
def index(self, index, body, doc_type='_doc', id=None, params=None):
def index(self, index, body, doc_type='_doc', id=None, params=None, headers=None):
if index not in self.__documents_dict:
self.__documents_dict[index] = list()

Expand Down Expand Up @@ -88,7 +88,7 @@ def index(self, index, body, doc_type='_doc', id=None, params=None):

@query_params('consistency', 'op_type', 'parent', 'refresh', 'replication',
'routing', 'timeout', 'timestamp', 'ttl', 'version', 'version_type')
def bulk(self, body, index=None, doc_type=None, params=None):
def bulk(self, body, index=None, doc_type=None, params=None, headers=None):
version = 1
items = []

Expand Down Expand Up @@ -128,7 +128,7 @@ def bulk(self, body, index=None, doc_type=None, params=None):
}

@query_params('parent', 'preference', 'realtime', 'refresh', 'routing')
def exists(self, index, doc_type, id, params=None):
def exists(self, index, doc_type, id, params=None, headers=None):
result = False
if index in self.__documents_dict:
for document in self.__documents_dict[index]:
Expand All @@ -140,7 +140,7 @@ def exists(self, index, doc_type, id, params=None):
@query_params('_source', '_source_exclude', '_source_include', 'fields',
'parent', 'preference', 'realtime', 'refresh', 'routing', 'version',
'version_type')
def get(self, index, id, doc_type='_all', params=None):
def get(self, index, id, doc_type='_all', params=None, headers=None):
result = None
if index in self.__documents_dict:
for document in self.__documents_dict[index]:
Expand Down Expand Up @@ -169,7 +169,7 @@ def get(self, index, id, doc_type='_all', params=None):
@query_params('_source', '_source_exclude', '_source_include', 'parent',
'preference', 'realtime', 'refresh', 'routing', 'version',
'version_type')
def get_source(self, index, doc_type, id, params=None):
def get_source(self, index, doc_type, id, params=None, headers=None):
document = self.get(index=index, doc_type=doc_type, id=id, params=params)
return document.get('_source')

Expand All @@ -181,7 +181,7 @@ def get_source(self, index, doc_type, id, params=None):
'size', 'sort', 'stats', 'suggest_field', 'suggest_mode',
'suggest_size', 'suggest_text', 'terminate_after', 'timeout',
'track_scores', 'version')
def count(self, index=None, doc_type=None, body=None, params=None):
def count(self, index=None, doc_type=None, body=None, params=None, headers=None):
searchable_indexes = self._normalize_index_to_list(index)

i = 0
Expand Down Expand Up @@ -209,7 +209,7 @@ def count(self, index=None, doc_type=None, body=None, params=None):
'size', 'sort', 'stats', 'suggest_field', 'suggest_mode',
'suggest_size', 'suggest_text', 'terminate_after', 'timeout',
'track_scores', 'version')
def search(self, index=None, doc_type=None, body=None, params=None):
def search(self, index=None, doc_type=None, body=None, params=None, headers=None):
searchable_indexes = self._normalize_index_to_list(index)

matches = []
Expand Down Expand Up @@ -273,7 +273,7 @@ def search(self, index=None, doc_type=None, body=None, params=None):
return result

@query_params('scroll')
def scroll(self, scroll_id, params=None):
def scroll(self, scroll_id, params=None, headers=None):
scroll = self.__scrolls.pop(scroll_id)
result = self.search(
index=scroll.get('index'),
Expand All @@ -285,7 +285,7 @@ def scroll(self, scroll_id, params=None):

@query_params('consistency', 'parent', 'refresh', 'replication', 'routing',
'timeout', 'version', 'version_type')
def delete(self, index, doc_type, id, params=None):
def delete(self, index, doc_type, id, params=None, headers=None):

found = False

Expand All @@ -311,7 +311,7 @@ def delete(self, index, doc_type, id, params=None):

@query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable',
'preference', 'routing')
def suggest(self, body, index=None, params=None):
def suggest(self, body, index=None, params=None, headers=None):
if index is not None and index not in self.__documents_dict:
raise NotFoundError(404, 'IndexMissingException[[{0}] missing]'.format(index))

Expand Down
8 changes: 4 additions & 4 deletions elasticmock/fake_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
class FakeIndicesClient(IndicesClient):

@query_params('master_timeout', 'timeout')
def create(self, index, body=None, params=None):
def create(self, index, body=None, params=None, headers=None):
documents_dict = self.__get_documents_dict()
if index not in documents_dict:
documents_dict[index] = []

@query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable',
'local')
def exists(self, index, params=None):
def exists(self, index, params=None, headers=None):
return index in self.__get_documents_dict()

@query_params('allow_no_indices', 'expand_wildcards', 'force',
'ignore_unavailable', 'operation_threading')
def refresh(self, index=None, params=None):
def refresh(self, index=None, params=None, headers=None):
pass

@query_params('master_timeout', 'timeout')
def delete(self, index, params=None):
def delete(self, index, params=None, headers=None):
documents_dict = self.__get_documents_dict()
if index in documents_dict:
del documents_dict[index]
Expand Down

0 comments on commit d6f58a3

Please sign in to comment.