This repository was archived by the owner on Apr 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +12
-18
lines changed
src/stapi_fastapi/routers Expand file tree Collapse file tree 3 files changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -184,7 +184,7 @@ async def get_orders(
184184 return collections
185185 case Failure (e ):
186186 logging .exception (f"An error occurred while retrieving orders: { e } " )
187- if isinstance (e , IndexError ):
187+ if isinstance (e , ValueError ):
188188 raise NotFoundException (detail = "Error finding pagination token" )
189189 else :
190190 raise HTTPException (
Original file line number Diff line number Diff line change @@ -55,18 +55,12 @@ async def get_orders(
5555 limit = 100
5656
5757 order_ids = [* self ._orders_db ._orders .keys ()]
58- if not order_ids and not next : # no data in db
59- return Success (
60- (
61- OrderCollection (
62- features = list (self ._orders_db ._orders .values ())
63- ),
64- "" ,
65- )
66- )
6758
6859 if next :
69- start = [i for i , x in enumerate (order_ids ) if x == next ][0 ]
60+ start = order_ids .index (next )
61+ if not order_ids and not next : # no data in db
62+ return Success ((OrderCollection (features = []), "" ))
63+
7064 end = start + limit
7165 ids = order_ids [start :end ]
7266 feats = [self ._orders_db ._orders [order_id ] for order_id in ids ]
Original file line number Diff line number Diff line change @@ -194,19 +194,19 @@ def create_order_payloads() -> list[OrderPayload]:
194194 return payloads
195195
196196
197- @pytest .fixture
198- def prepare_order_pagination (
199- stapi_client : TestClient , create_order_payloads : list [OrderPayload ]
200- ) -> None :
201- product_id = "test-spotlight"
202-
203- # check empty
197+ def test_empty_order (stapi_client : TestClient ):
204198 res = stapi_client .get ("/orders" )
205199 default_orders = {"type" : "FeatureCollection" , "features" : [], "links" : []}
206200 assert res .status_code == status .HTTP_200_OK
207201 assert res .headers ["Content-Type" ] == "application/geo+json"
208202 assert res .json () == default_orders
209203
204+
205+ @pytest .fixture
206+ def prepare_order_pagination (
207+ stapi_client : TestClient , create_order_payloads : list [OrderPayload ]
208+ ) -> None :
209+ product_id = "test-spotlight"
210210 # get uuids created to use as pagination tokens
211211 for payload in create_order_payloads :
212212 res = stapi_client .post (
You can’t perform that action at this time.
0 commit comments