@@ -1665,6 +1665,26 @@ async def test_filter_by_id(app_client, ctx):
16651665 assert resp_json ["features" ][0 ]["id" ] == item_id
16661666 assert resp_json ["features" ][0 ]["collection" ] == collection_id
16671667
1668+ # Create a non-existent ID
1669+ non_existent_id = f"non-existent-{ str (uuid .uuid4 ())} "
1670+
1671+ filter_body = {"op" : "=" , "args" : [{"property" : "id" }, non_existent_id ]}
1672+
1673+ # Make the request with the filter
1674+ params = [("filter" , json .dumps (filter_body )), ("filter-lang" , "cql2-json" )]
1675+
1676+ resp = await app_client .get (
1677+ f"/collections/{ collection_id } /items" ,
1678+ params = params ,
1679+ )
1680+
1681+ # Verify the response
1682+ assert resp .status_code == 200
1683+ resp_json = resp .json ()
1684+
1685+ # Should find exactly one matching item
1686+ assert len (resp_json ["features" ]) == 0
1687+
16681688
16691689@pytest .mark .asyncio
16701690async def test_filter_by_nonexistent_id (app_client , ctx , txn_client ):
@@ -1683,13 +1703,14 @@ async def test_filter_by_nonexistent_id(app_client, ctx, txn_client):
16831703 # Create a filter with the non-existent ID using CQL2-JSON syntax
16841704 filter_body = {"op" : "=" , "args" : [{"property" : "id" }, non_existent_id ]}
16851705
1686- # Make the request with the filter
1687- params = [( "filter" , json . dumps ( filter_body )), ( "filter-lang" , "cql2-json" )]
1706+ # URL-encode the filter JSON
1707+ import urllib . parse
16881708
1689- resp = await app_client .get (
1690- f"/collections/{ collection_id } /items" ,
1691- params = params ,
1692- )
1709+ encoded_filter = urllib .parse .quote (json .dumps (filter_body ))
1710+
1711+ # Make the request with URL-encoded filter in the query string
1712+ url = f"/collections/{ collection_id } /items?filter-lang=cql2-json&filter={ encoded_filter } "
1713+ resp = await app_client .get (url )
16931714
16941715 # Verify the response
16951716 assert resp .status_code == 200
0 commit comments