@@ -6,6 +6,8 @@ def test_basic_search(index_with_documents):
6
6
response = index_with_documents ().search ("How to Train Your Dragon" )
7
7
assert isinstance (response , dict )
8
8
assert response ["hits" ][0 ]["id" ] == "166428"
9
+ assert response ["estimatedTotalHits" ] is not None
10
+ assert "hitsPerPage" is not response
9
11
10
12
11
13
def test_basic_search_with_empty_params (index_with_documents ):
@@ -413,3 +415,29 @@ def test_custom_search_params_with_matching_strategy_last(index_with_documents):
413
415
414
416
assert isinstance (response , dict )
415
417
assert len (response ["hits" ]) > 1
418
+
419
+
420
+ def test_custom_search_params_with_pagination_parameters (index_with_documents ):
421
+ """Tests search with matching strategy param set to last"""
422
+ response = index_with_documents ().search ("" , {"hitsPerPage" : 1 , "page" : 1 })
423
+
424
+ assert isinstance (response , dict )
425
+ assert len (response ["hits" ]) == 1
426
+ assert response ["hitsPerPage" ] == 1
427
+ assert response ["page" ] == 1
428
+ assert response ["totalPages" ] is not None
429
+ assert response ["totalHits" ] is not None
430
+ assert "estimatedTotalHits" is not response
431
+
432
+
433
+ def test_custom_search_params_with_pagination_parameters_at_zero (index_with_documents ):
434
+ """Tests search with matching strategy param set to last"""
435
+ response = index_with_documents ().search ("" , {"hitsPerPage" : 0 , "page" : 0 })
436
+
437
+ assert isinstance (response , dict )
438
+ assert len (response ["hits" ]) == 0
439
+ assert response ["hitsPerPage" ] == 0
440
+ assert response ["page" ] == 0
441
+ assert response ["totalPages" ] is not None
442
+ assert response ["totalHits" ] is not None
443
+ assert "estimatedTotalHits" is not response
0 commit comments