Skip to content

Commit c213602

Browse files
committed
Add search tests: empty string and empty query (placeholder search)
1 parent c2585f3 commit c213602

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

meilisearch/tests/index/test_index_search_meilisearch.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ def test_basic_search_with_empty_params(self):
4141
assert response['hits'][0]['id'] == '166428'
4242
assert '_formatted' not in response['hits'][0]
4343

44+
def test_basic_search_with_empty_query(self):
45+
"""Tests search with empty query and empty params"""
46+
response = self.index.search('', {})
47+
assert isinstance(response, object)
48+
assert len(response['hits']) == 0
49+
50+
def test_basic_search_with_placeholder(self):
51+
"""Tests search with no query [None] and empty params"""
52+
response = self.index.search(None, {})
53+
assert isinstance(response, object)
54+
assert len(response['hits']) == 20
55+
4456
def test_custom_search(self):
4557
"""Tests search with an simple query and custom parameter (attributesToHighlight)"""
4658
response = self.index.search(
@@ -54,6 +66,17 @@ def test_custom_search(self):
5466
assert '_formatted' in response['hits'][0]
5567
assert 'dragon' in response['hits'][0]['_formatted']['title'].lower()
5668

69+
def test_custom_search_with_placeholder(self):
70+
"""Tests search with no query [None] and custom parameter (attributesToHighlight)"""
71+
response = self.index.search(
72+
None,
73+
{
74+
'limit': 5
75+
}
76+
)
77+
assert isinstance(response, object)
78+
assert len(response['hits']) == 5
79+
5780
def test_custom_search_params_with_wildcard(self):
5881
"""Tests search with '*' in query params"""
5982
response = self.index.search(

0 commit comments

Comments
 (0)