@@ -1503,40 +1503,37 @@ async def test_search_datetime_validation_errors(app_client):
15031503 assert resp .status_code == 400
15041504
15051505
1506- async def test_get_filter_cql2text (app_client , load_test_data , load_test_collection ):
1506+ @pytest .mark .parametrize (
1507+ "cql2_filter,expected_count" ,
1508+ [
1509+ ("true" , 1 ),
1510+ ("proj:epsg=32756" , 1 ),
1511+ ("proj:epsg=32756 AND collection = 'test-collection'" , 1 ),
1512+ ("false" , 1 ), # Bad boolean
1513+ ("proj:epsg=11111" , 0 ), # Bad epsg
1514+ ("proj:epsg=32756 AND collection = 'bad-collection'" , 0 ), # Bad collection
1515+ ],
1516+ )
1517+ async def test_get_filter_cql2text (
1518+ app_client , load_test_data , load_test_collection , cql2_filter , expected_count
1519+ ):
15071520 """Test GET search with cql2-text"""
15081521 test_item = load_test_data ("test_item.json" )
15091522 resp = await app_client .post (
15101523 f"/collections/{ test_item ['collection' ]} /items" , json = test_item
15111524 )
15121525 assert resp .status_code == 201
15131526
1514- epsg = test_item ["properties" ]["proj:epsg" ]
1515- collection = test_item ["collection" ]
1516-
1517- filter = f"proj:epsg={ epsg } AND collection = '{ collection } '"
1518- params = {"filter" : filter , "filter-lang" : "cql2-text" }
1519- resp = await app_client .get ("/search" , params = params )
1520- resp_json = resp .json ()
1521- assert len (resp .json ()["features" ]) == 1
1522- assert (
1523- resp_json ["features" ][0 ]["properties" ]["proj:epsg" ]
1524- == test_item ["properties" ]["proj:epsg" ]
1525- )
1526-
1527- filter = f"proj:epsg={ epsg + 1 } AND collection = '{ collection } '"
1528- params = {"filter" : filter , "filter-lang" : "cql2-text" }
1529- resp = await app_client .get ("/search" , params = params )
1530- resp_json = resp .json ()
1531- assert len (resp .json ()["features" ]) == 0
1532-
1533- filter = f"proj:epsg={ epsg } "
1534- params = {"filter" : filter , "filter-lang" : "cql2-text" }
15351527 resp = await app_client .get (
1536- f"/collections/ { test_item [ 'collection' ] } /items " , params = params
1528+ "/search " , params = { "filter" : cql2_filter , "filter-lang" : "cql2-text" }
15371529 )
15381530 resp_json = resp .json ()
1539- assert len (resp .json ()["features" ]) == 1
1531+ assert len (resp .json ()["features" ]) == expected_count
1532+ if expected_count == 1 :
1533+ assert (
1534+ resp_json ["features" ][0 ]["properties" ]["proj:epsg" ]
1535+ == test_item ["properties" ]["proj:epsg" ]
1536+ )
15401537
15411538
15421539async def test_item_merge_raster_bands (
0 commit comments