@@ -271,6 +271,47 @@ async def test_app_query_extension_gte(load_test_data, app_client, load_test_col
271271 assert len (resp_json ["features" ]) == 1
272272
273273
274+ async def test_app_collection_fields_extension (
275+ load_test_data , app_client , load_test_collection , app
276+ ):
277+ fields = ["title" ]
278+ resp = await app_client .get ("/collections" , params = {"fields" : "," .join (fields )})
279+
280+ assert resp .status_code == 200
281+
282+ resp_json = resp .json ()
283+ resp_collections = resp_json ["collections" ]
284+
285+ assert len (resp_collections ) > 0
286+ # NOTE: It's a bug that 'collection' is always included; see #327
287+ constant_fields = ["id" , "links" , "collection" ]
288+ for collection in resp_collections :
289+ assert set (collection .keys ()) == set (fields + constant_fields )
290+
291+
292+ async def test_app_item_fields_extension (
293+ load_test_data , app_client , load_test_collection , load_test_item , app
294+ ):
295+ coll = load_test_collection
296+ fields = ["id" , "geometry" ]
297+ resp = await app_client .get (
298+ f"/collections/{ coll ['id' ]} /items" , params = {"fields" : "," .join (fields )}
299+ )
300+
301+ assert resp .status_code == 200
302+
303+ resp_json = resp .json ()
304+ features = resp_json ["features" ]
305+
306+ assert len (features ) > 0
307+ # These fields are always included in items
308+ constant_fields = ["id" , "links" ]
309+ if not app .state .settings .use_api_hydrate :
310+ constant_fields .append ("collection" )
311+ for item in features :
312+ assert set (item .keys ()) == set (fields + constant_fields )
313+
314+
274315async def test_app_sort_extension (load_test_data , app_client , load_test_collection ):
275316 coll = load_test_collection
276317 first_item = load_test_data ("test_item.json" )
0 commit comments