From 758095ec47649964126543d92527248b5ac62484 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 24 Sep 2024 22:14:01 +0200 Subject: [PATCH 1/2] Removed `cql2-text` in supported `filter-lang` for `FilterExtensionPostRequest` model --- CHANGES.md | 4 ++++ .../extensions/stac_fastapi/extensions/core/filter/request.py | 2 +- stac_fastapi/extensions/tests/test_filter.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8c407e70..226791a1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Removed + +* Removed `cql2-text` in supported `filter-lang` for `FilterExtensionPostRequest` model (as per specification) + ## [3.0.2] - 2024-09-20 ### Added diff --git a/stac_fastapi/extensions/stac_fastapi/extensions/core/filter/request.py b/stac_fastapi/extensions/stac_fastapi/extensions/core/filter/request.py index 30ac011b..dae56a51 100644 --- a/stac_fastapi/extensions/stac_fastapi/extensions/core/filter/request.py +++ b/stac_fastapi/extensions/stac_fastapi/extensions/core/filter/request.py @@ -70,7 +70,7 @@ class FilterExtensionPostRequest(BaseModel): default=None, description="The coordinate reference system (CRS) used by spatial literals in the 'filter' value. Default is `http://www.opengis.net/def/crs/OGC/1.3/CRS84`", # noqa: E501 ) - filter_lang: Optional[FilterLang] = Field( + filter_lang: Optional[Literal["cql-json", "cql2-json"]] = Field( alias="filter-lang", default="cql2-json", description="The CQL filter encoding that the 'filter' value uses.", diff --git a/stac_fastapi/extensions/tests/test_filter.py b/stac_fastapi/extensions/tests/test_filter.py index a13fb14c..85db5261 100644 --- a/stac_fastapi/extensions/tests/test_filter.py +++ b/stac_fastapi/extensions/tests/test_filter.py @@ -62,12 +62,12 @@ def test_search_filter_post_filter_lang_default(client: TestClient): def test_search_filter_post_filter_lang_non_default(client: TestClient): """Test search POST endpoint with filter ext.""" - filter_lang_value = "cql2-text" + filter_lang_value = "cql-json" response = client.post( "/search", json={ "collections": ["test"], - "filter": {"op": "=", "args": [{"property": "test_property"}, "test-value"]}, + "filter": {"eq": [{"property": "test_property"}, "test-value"]}, "filter-lang": filter_lang_value, }, ) From 381c637d650de98a9841240ca4e1c8b9a4324926 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 24 Sep 2024 22:19:27 +0200 Subject: [PATCH 2/2] update tests --- stac_fastapi/api/tests/test_app.py | 2 +- stac_fastapi/api/tests/test_models.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stac_fastapi/api/tests/test_app.py b/stac_fastapi/api/tests/test_app.py index 0ddcb242..0887a62e 100644 --- a/stac_fastapi/api/tests/test_app.py +++ b/stac_fastapi/api/tests/test_app.py @@ -191,7 +191,7 @@ def get_search( "collections": ["test"], "filter": {}, "filter-crs": "EPSG:4326", - "filter-lang": "cql2-text", + "filter-lang": "cql2-json", }, ) diff --git a/stac_fastapi/api/tests/test_models.py b/stac_fastapi/api/tests/test_models.py index b0c2ad90..1df385d9 100644 --- a/stac_fastapi/api/tests/test_models.py +++ b/stac_fastapi/api/tests/test_models.py @@ -63,7 +63,7 @@ def route(model=Depends(request_model)): @pytest.mark.parametrize( "filter,passes", - [(None, True), ({"test": "test"}, True), ("test==test", False), ([], False)], + [(None, True), ({"test": "test"}, True), ([], False)], ) def test_create_post_request_model(filter, passes): request_model = create_post_request_model( @@ -82,7 +82,7 @@ def test_create_post_request_model(filter, passes): datetime="2020-01-01T00:00:00Z", limit=10, filter=filter, - **{"filter-crs": "epsg:4326", "filter-lang": "cql2-text"}, + **{"filter-crs": "epsg:4326", "filter-lang": "cql2-json"}, ) assert model.collections == ["test1", "test2"]