Skip to content

Commit 441b507

Browse files
authored
Merge pull request #595 from meilisearch/add_pagination_feature_for_v0.30.0
Add pagination feature for v0.30.0
2 parents 753a826 + a5d40a2 commit 441b507

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/index/test_index_search_meilisearch.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ def test_basic_search(index_with_documents):
66
response = index_with_documents().search("How to Train Your Dragon")
77
assert isinstance(response, dict)
88
assert response["hits"][0]["id"] == "166428"
9+
assert response["estimatedTotalHits"] is not None
10+
assert "hitsPerPage" is not response
911

1012

1113
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):
413415

414416
assert isinstance(response, dict)
415417
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

Comments
 (0)