File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
runtime/eoapi/raster/eoapi/raster Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -188,3 +188,16 @@ def test_item():
188188 in resp .json ()["tiles" ][0 ]
189189 )
190190 assert resp .json ()["bounds" ] == [- 85.5501 , 36.1749 , - 85.5249 , 36.2001 ]
191+
192+
193+ def test_collections ():
194+ """test collection endpoints."""
195+ resp = httpx .get (
196+ f"{ raster_endpoint } /collections" ,
197+ )
198+ assert resp .status_code == 200
199+ assert resp .headers ["content-type" ] == "application/json"
200+
201+ collections = resp .json ()
202+ assert len (collections ) == 1
203+ assert collections [0 ]["id" ] == "noaa-emergency-response"
Original file line number Diff line number Diff line change 99from eoapi .raster .config import ApiSettings
1010from fastapi import Depends , FastAPI , Query
1111from psycopg import OperationalError
12+ from psycopg .rows import dict_row
1213from psycopg_pool import PoolTimeout
1314from starlette .middleware .cors import CORSMiddleware
1415from starlette .requests import Request
@@ -118,9 +119,10 @@ async def mosaic_builder(request: Request):
118119async def list_collection (request : Request ):
119120 """list collections."""
120121 with request .app .state .dbpool .connection () as conn :
121- with conn .cursor () as cursor :
122- cursor .execute ("SELECT * FROM collections;" )
123- return [t [2 ] for t in cursor .fetchall () if t ]
122+ with conn .cursor (row_factory = dict_row ) as cursor :
123+ cursor .execute ("SELECT * FROM pgstac.all_collections();" )
124+ r = cursor .fetchone ()
125+ return r .get ("all_collections" , [])
124126
125127
126128app .include_router (mosaic .router , tags = ["Mosaic" ], prefix = "/mosaic" )
You can’t perform that action at this time.
0 commit comments