Skip to content

Commit c92c88a

Browse files
committed
demonstrate issue 713
1 parent 8f400e1 commit c92c88a

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

stac_fastapi/extensions/tests/test_filter.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def get_item(self, *args, **kwargs):
2121
raise NotImplementedError
2222

2323
def get_search(self, *args, **kwargs):
24-
raise NotImplementedError
24+
_ = kwargs.pop("request", None)
25+
return kwargs
2526

2627
def post_search(self, *args, **kwargs):
2728
return args[0].model_dump()
@@ -73,3 +74,36 @@ def test_search_filter_post_filter_lang_non_default(client: TestClient):
7374
assert response.is_success, response.json()
7475
response_dict = response.json()
7576
assert response_dict["filter_lang"] == filter_lang_value
77+
78+
79+
def test_search_filter_get(client: TestClient):
80+
"""Test search GET endpoint with filter ext."""
81+
response = client.get(
82+
"/search",
83+
params={
84+
"filter": "id='item_id' AND collection='collection_id'",
85+
},
86+
)
87+
assert response.is_success, response.json()
88+
response_dict = response.json()
89+
assert not response_dict["collections"]
90+
assert response_dict["filter"] == "id='item_id' AND collection='collection_id'"
91+
assert not response_dict["filter_crs"]
92+
assert response_dict["filter_lang"] == "cql2-text"
93+
94+
response = client.get(
95+
"/search",
96+
params={
97+
"filter": {"op": "=", "args": [{"property": "id"}, "test-item"]},
98+
"filter-lang": "cql2-json",
99+
},
100+
)
101+
assert response.is_success, response.json()
102+
response_dict = response.json()
103+
assert not response_dict["collections"]
104+
assert (
105+
response_dict["filter"]
106+
== "{'op': '=', 'args': [{'property': 'id'}, 'test-item']}"
107+
)
108+
assert not response_dict["filter_crs"]
109+
assert response_dict["filter_lang"] == "cql2-json"

0 commit comments

Comments
 (0)