@@ -41,6 +41,19 @@ def test_basic_search_with_empty_params(self):
41
41
assert response ['hits' ][0 ]['id' ] == '166428'
42
42
assert '_formatted' not in response ['hits' ][0 ]
43
43
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
+ assert response ['query' ] == ''
50
+
51
+ def test_basic_search_with_placeholder (self ):
52
+ """Tests search with no query [None] and empty params"""
53
+ response = self .index .search (None , {})
54
+ assert isinstance (response , object )
55
+ assert len (response ['hits' ]) == 20
56
+
44
57
def test_custom_search (self ):
45
58
"""Tests search with an simple query and custom parameter (attributesToHighlight)"""
46
59
response = self .index .search (
@@ -54,6 +67,29 @@ def test_custom_search(self):
54
67
assert '_formatted' in response ['hits' ][0 ]
55
68
assert 'dragon' in response ['hits' ][0 ]['_formatted' ]['title' ].lower ()
56
69
70
+ def test_custom_search_with_empty_query (self ):
71
+ """Tests search with empty query and custom parameter (attributesToHighlight)"""
72
+ response = self .index .search (
73
+ '' ,
74
+ {
75
+ 'attributesToHighlight' : ['title' ]
76
+ }
77
+ )
78
+ assert isinstance (response , object )
79
+ assert len (response ['hits' ]) == 0
80
+ assert response ['query' ] == ''
81
+
82
+ def test_custom_search_with_placeholder (self ):
83
+ """Tests search with no query [None] and custom parameter (limit)"""
84
+ response = self .index .search (
85
+ None ,
86
+ {
87
+ 'limit' : 5
88
+ }
89
+ )
90
+ assert isinstance (response , object )
91
+ assert len (response ['hits' ]) == 5
92
+
57
93
def test_custom_search_params_with_wildcard (self ):
58
94
"""Tests search with '*' in query params"""
59
95
response = self .index .search (
0 commit comments