@@ -598,3 +598,52 @@ def test_output_response_type(app):
598598 assert response .headers ["content-type" ] == "application/ndjson"
599599 body = response .text .splitlines ()
600600 assert len (body ) == 10
601+
602+
603+ def test_items_sortby (app ):
604+ """Test /items endpoint with sortby options."""
605+ response = app .get ("/collections/public.landsat_wrs/items?limit=1" )
606+ assert response .status_code == 200
607+ assert response .headers ["content-type" ] == "application/geo+json"
608+ body = response .json ()
609+ assert body ["features" ][0 ]["properties" ]["ogc_fid" ] == 1
610+ assert body ["numberMatched" ] == 16269
611+
612+ response = app .get ("/collections/public.landsat_wrs/items?limit=1&sortby=ogc_fid" )
613+ assert response .status_code == 200
614+ assert response .headers ["content-type" ] == "application/geo+json"
615+ body = response .json ()
616+ assert body ["features" ][0 ]["properties" ]["ogc_fid" ] == 1
617+ assert body ["numberMatched" ] == 16269
618+
619+ response = app .get ("/collections/public.landsat_wrs/items?limit=1&sortby=row" )
620+ assert response .status_code == 200
621+ body = response .json ()
622+ assert body ["features" ][0 ]["properties" ]["row" ] == 1
623+ assert body ["numberMatched" ] == 16269
624+
625+ response = app .get ("/collections/public.landsat_wrs/items?limit=1&sortby=+row" )
626+ assert response .status_code == 200
627+ body = response .json ()
628+ assert body ["features" ][0 ]["properties" ]["row" ] == 1
629+
630+ response = app .get ("/collections/public.landsat_wrs/items?limit=1&sortby=-row" )
631+ assert response .status_code == 200
632+ body = response .json ()
633+ assert body ["features" ][0 ]["properties" ]["row" ] == 248
634+
635+ response = app .get ("/collections/public.landsat_wrs/items?limit=1&sortby=-row,path" )
636+ assert response .status_code == 200
637+ body = response .json ()
638+ assert body ["features" ][0 ]["properties" ]["row" ] == 248
639+ assert body ["features" ][0 ]["properties" ]["path" ] == 1
640+
641+ response = app .get ("/collections/public.landsat_wrs/items?limit=1&sortby=path,-row" )
642+ assert response .status_code == 200
643+ body = response .json ()
644+ assert body ["features" ][0 ]["properties" ]["row" ] == 248
645+ assert body ["features" ][0 ]["properties" ]["path" ] == 1
646+
647+ # Invalid column name
648+ response = app .get ("/collections/public.landsat_wrs/items?limit=1&sortby=something" )
649+ assert response .status_code == 404
0 commit comments