Skip to content

add tests for CQL2-JSON IN operator #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion tests/resources/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,12 @@ async def test_item_search_post_filter_extension_cql2(
)
assert resp.status_code == 201

# make sure we have 2 items
resp = await app_client.post("/search", json={})
resp_json = resp.json()
assert resp.status_code == 200
assert len(resp_json.get("features")) == 2

# EPSG is a JSONB key
params = {
"collections": [test_item["collection"]],
Expand Down Expand Up @@ -887,6 +893,39 @@ async def test_item_search_post_filter_extension_cql2(
== test_item["properties"]["proj:epsg"]
)

# Test IN operator
params = {
"collections": [test_item["collection"]],
"filter-lang": "cql2-json",
"filter": {
"op": "in",
"args": [
{"property": "proj:epsg"},
[test_item["properties"]["proj:epsg"]],
],
},
}
resp = await app_client.post("/search", json=params)
resp_json = resp.json()
assert resp.status_code == 200
assert len(resp_json.get("features")) == 1

params = {
"collections": [test_item["collection"]],
"filter-lang": "cql2-json",
"filter": {
"op": "in",
"args": [
{"property": "proj:epsg"},
[test_item["properties"]["proj:epsg"] + 1],
],
},
}
resp = await app_client.post("/search", json=params)
resp_json = resp.json()
assert resp.status_code == 200
assert len(resp_json.get("features")) == 0


async def test_item_search_post_filter_extension_cql2_with_query_fails(
app_client, load_test_data, load_test_collection
Expand All @@ -904,7 +943,7 @@ async def test_item_search_post_filter_extension_cql2_with_query_fails(
)
assert resp.status_code == 201

# EPSG is a JSONB key
# Cannot use `query` and `filter`
params = {
"collections": [test_item["collection"]],
"filter-lang": "cql2-json",
Expand Down
Loading