diff --git a/elasticmock/fake_elasticsearch.py b/elasticmock/fake_elasticsearch.py index 98e5a6e..35ed315 100644 --- a/elasticmock/fake_elasticsearch.py +++ b/elasticmock/fake_elasticsearch.py @@ -343,6 +343,7 @@ def count(self, index=None, doc_type=None, body=None, params=None, headers=None) 'count': i, '_shards': { 'successful': 1, + 'skipped': 0, 'failed': 0, 'total': 1 } @@ -394,6 +395,7 @@ def search(self, index=None, doc_type=None, body=None, params=None, headers=None '_shards': { # Simulate indexes with 1 shard each 'successful': len(searchable_indexes), + 'skipped': 0, 'failed': 0, 'total': len(searchable_indexes) }, diff --git a/tests/fake_elasticsearch/test_count.py b/tests/fake_elasticsearch/test_count.py index 6aed8ea..a481f40 100644 --- a/tests/fake_elasticsearch/test_count.py +++ b/tests/fake_elasticsearch/test_count.py @@ -26,6 +26,11 @@ def test_should_count_with_empty_doc_types(self): count = self.es.count(doc_type=[]) self.assertEqual(1, count.get('count')) + def test_should_return_skipped_shards(self): + self.es.index(index='index', doc_type=DOC_TYPE, body={'data': 'test'}) + count = self.es.count(doc_type=[]) + self.assertEqual(0, count.get('_shards').get('skipped')) + def test_should_count_with_doc_types(self): self.es.index(index='index', doc_type=DOC_TYPE, body={'data': 'test1'}) self.es.index(index='index', doc_type='different-doc-type', body={'data': 'test2'}) diff --git a/tests/fake_elasticsearch/test_search.py b/tests/fake_elasticsearch/test_search.py index 74079fe..e482c1f 100644 --- a/tests/fake_elasticsearch/test_search.py +++ b/tests/fake_elasticsearch/test_search.py @@ -16,6 +16,10 @@ def test_should_return_hits_hits_even_when_no_result(self): self.assertEqual(0, search.get('hits').get('total')) self.assertListEqual([], search.get('hits').get('hits')) + def test_should_return_skipped_shards(self): + search = self.es.search() + self.assertEqual(0, search.get('_shards').get('skipped')) + def test_should_return_all_documents(self): index_quantity = 10 for i in range(0, index_quantity):