Skip to content

Commit 42cea5d

Browse files
add tests for CQL2-JSON IN operator (#241)
1 parent db9d81c commit 42cea5d

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

tests/resources/test_item.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,12 @@ async def test_item_search_post_filter_extension_cql2(
850850
)
851851
assert resp.status_code == 201
852852

853+
# make sure we have 2 items
854+
resp = await app_client.post("/search", json={})
855+
resp_json = resp.json()
856+
assert resp.status_code == 200
857+
assert len(resp_json.get("features")) == 2
858+
853859
# EPSG is a JSONB key
854860
params = {
855861
"collections": [test_item["collection"]],
@@ -887,6 +893,39 @@ async def test_item_search_post_filter_extension_cql2(
887893
== test_item["properties"]["proj:epsg"]
888894
)
889895

896+
# Test IN operator
897+
params = {
898+
"collections": [test_item["collection"]],
899+
"filter-lang": "cql2-json",
900+
"filter": {
901+
"op": "in",
902+
"args": [
903+
{"property": "proj:epsg"},
904+
[test_item["properties"]["proj:epsg"]],
905+
],
906+
},
907+
}
908+
resp = await app_client.post("/search", json=params)
909+
resp_json = resp.json()
910+
assert resp.status_code == 200
911+
assert len(resp_json.get("features")) == 1
912+
913+
params = {
914+
"collections": [test_item["collection"]],
915+
"filter-lang": "cql2-json",
916+
"filter": {
917+
"op": "in",
918+
"args": [
919+
{"property": "proj:epsg"},
920+
[test_item["properties"]["proj:epsg"] + 1],
921+
],
922+
},
923+
}
924+
resp = await app_client.post("/search", json=params)
925+
resp_json = resp.json()
926+
assert resp.status_code == 200
927+
assert len(resp_json.get("features")) == 0
928+
890929

891930
async def test_item_search_post_filter_extension_cql2_with_query_fails(
892931
app_client, load_test_data, load_test_collection
@@ -904,7 +943,7 @@ async def test_item_search_post_filter_extension_cql2_with_query_fails(
904943
)
905944
assert resp.status_code == 201
906945

907-
# EPSG is a JSONB key
946+
# Cannot use `query` and `filter`
908947
params = {
909948
"collections": [test_item["collection"]],
910949
"filter-lang": "cql2-json",

0 commit comments

Comments
 (0)