@@ -1667,15 +1667,21 @@ async def test_filter_by_id(app_client, ctx):
16671667
16681668
16691669@pytest .mark .asyncio
1670- async def test_filter_by_nonexistent_id (app_client , ctx ):
1670+ async def test_filter_by_nonexistent_id (app_client , ctx , txn_client ):
16711671 """Test filtering with a non-existent ID returns no results."""
1672- collection_id = ctx .item ["collection" ]
1672+ # Get the test collection and item from context
1673+ collection_id = ctx .collection ["id" ]
1674+ item_id = ctx .item ["id" ]
16731675
1674- # Create a filter with a non-existent ID
1675- filter_body = {
1676- "op" : "=" ,
1677- "args" : [{"property" : "id" }, "this-id-does-not-exist-12345" ],
1678- }
1676+ # First, verify the item exists
1677+ resp = await app_client .get (f"/collections/{ collection_id } /items/{ item_id } " )
1678+ assert resp .status_code == 200
1679+
1680+ # Create a non-existent ID
1681+ non_existent_id = f"non-existent-{ str (uuid .uuid4 ())} "
1682+
1683+ # Create a filter with the non-existent ID using CQL2-JSON syntax
1684+ filter_body = {"op" : "=" , "args" : [{"property" : "id" }, non_existent_id ]}
16791685
16801686 # Make the request with the filter
16811687 params = [("filter" , json .dumps (filter_body )), ("filter-lang" , "cql2-json" )]
@@ -1688,4 +1694,6 @@ async def test_filter_by_nonexistent_id(app_client, ctx):
16881694 # Verify the response
16891695 assert resp .status_code == 200
16901696 resp_json = resp .json ()
1691- assert len (resp_json ["features" ]) == 0
1697+ assert (
1698+ len (resp_json ["features" ]) == 0
1699+ ), f"Expected no items with ID { non_existent_id } , but found { len (resp_json ['features' ])} matches"
0 commit comments