Skip to content

Commit

Permalink
demonstrate issue 713
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Jun 24, 2024
1 parent 8f400e1 commit c92c88a
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion stac_fastapi/extensions/tests/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def get_item(self, *args, **kwargs):
raise NotImplementedError

def get_search(self, *args, **kwargs):
raise NotImplementedError
_ = kwargs.pop("request", None)
return kwargs

def post_search(self, *args, **kwargs):
return args[0].model_dump()
Expand Down Expand Up @@ -73,3 +74,36 @@ def test_search_filter_post_filter_lang_non_default(client: TestClient):
assert response.is_success, response.json()
response_dict = response.json()
assert response_dict["filter_lang"] == filter_lang_value


def test_search_filter_get(client: TestClient):
"""Test search GET endpoint with filter ext."""
response = client.get(
"/search",
params={
"filter": "id='item_id' AND collection='collection_id'",
},
)
assert response.is_success, response.json()
response_dict = response.json()
assert not response_dict["collections"]
assert response_dict["filter"] == "id='item_id' AND collection='collection_id'"
assert not response_dict["filter_crs"]
assert response_dict["filter_lang"] == "cql2-text"

response = client.get(
"/search",
params={
"filter": {"op": "=", "args": [{"property": "id"}, "test-item"]},
"filter-lang": "cql2-json",
},
)
assert response.is_success, response.json()
response_dict = response.json()
assert not response_dict["collections"]
assert (
response_dict["filter"]
== "{'op': '=', 'args': [{'property': 'id'}, 'test-item']}"
)
assert not response_dict["filter_crs"]
assert response_dict["filter_lang"] == "cql2-json"

0 comments on commit c92c88a

Please sign in to comment.