Skip to content

Commit

Permalink
fix(elasticsearch): from query param not passed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
wiwski committed Jun 26, 2024
1 parent 4d35270 commit 4a2ec2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lab/elasticsearch/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions lab/elasticsearch/tests/test_queries.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest import mock

from .. import queries
from ._mock import BASE_SEARCH_PARAMS, BASE_SEARCH_PARAMS_RELATED_QUERY

Expand Down Expand Up @@ -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")

0 comments on commit 4a2ec2c

Please sign in to comment.