From 4a2ec2cdda78b50ea835efaf34f8e0b7c2127e30 Mon Sep 17 00:00:00 2001 From: witold Date: Wed, 26 Jun 2024 16:12:41 +0200 Subject: [PATCH] fix(elasticsearch): from query param not passed correctly --- lab/elasticsearch/queries.py | 2 +- lab/elasticsearch/tests/test_queries.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lab/elasticsearch/queries.py b/lab/elasticsearch/queries.py index 85ad59c28..83ea9c1a7 100644 --- a/lab/elasticsearch/queries.py +++ b/lab/elasticsearch/queries.py @@ -139,7 +139,7 @@ def filter_query( params: QueryParams, ): size = params.pop("size", None) - _from = params.pop("_from", None) + _from = params.pop("from", None) sort = params.pop("sort", None) return Query().build_query( params, diff --git a/lab/elasticsearch/tests/test_queries.py b/lab/elasticsearch/tests/test_queries.py index cbd2ded59..ea100ac74 100644 --- a/lab/elasticsearch/tests/test_queries.py +++ b/lab/elasticsearch/tests/test_queries.py @@ -1,3 +1,5 @@ +from unittest import mock + from .. import queries from ._mock import BASE_SEARCH_PARAMS, BASE_SEARCH_PARAMS_RELATED_QUERY @@ -43,3 +45,9 @@ def test_date_historiogram_agg_query(): } }, } + + +def test_filter_query(): + with mock.patch("lab.elasticsearch.queries.Query.build_query") as mock_build_query: + queries.filter_query({"size": 50, "from": 40, "sort": "desc"}) + mock_build_query.assert_called_with({}, size=50, _from=40, sort="desc")