@@ -347,9 +347,8 @@ async def test_get_collections_search_limit_offset(
347347 assert len (cols ) == 2
348348 assert cols [0 ]["id" ] == load_test_collection ["id" ]
349349 assert cols [1 ]["id" ] == load_test2_collection .id
350- # TODO: check with pgstac
351- # assert len(links) == 2
352- # assert {"root", "self"} == {link["rel"] for link in links}
350+ assert len (links ) == 2
351+ assert {"root" , "self" } == {link ["rel" ] for link in links }
353352
354353 ###################
355354 # limit=3, there should not be a next/previous link
@@ -406,20 +405,36 @@ async def test_get_collections_search_limit_offset(
406405 assert prev_link ["href" ].endswith ("?limit=2&offset=1" )
407406
408407 ###################
409- # offset=1, should have a `previous` link
408+ # offset=1,limit=1 should have a `previous` link
410409 resp = await app_client .get (
411410 "/collections" ,
412- params = {"offset" : 1 },
411+ params = {"offset" : 1 , "limit" : 1 },
413412 )
414413 cols = resp .json ()["collections" ]
415414 links = resp .json ()["links" ]
416415 assert len (cols ) == 1
417416 assert cols [0 ]["id" ] == load_test2_collection .id
418- # TODO: Check with pgstac
417+ assert len (links ) == 3
418+ assert {"root" , "self" , "previous" } == {link ["rel" ] for link in links }
419+ prev_link = list (filter (lambda link : link ["rel" ] == "previous" , links ))[0 ]
420+ assert "offset" not in prev_link ["href" ]
421+
422+ ###################
423+ # BUG: pgstac doesn't return a `prev` link when limit is not set
424+ # offset=1, should have a `previous` link
425+ # resp = await app_client.get(
426+ # "/collections",
427+ # params={"offset": 1},
428+ # )
429+ # cols = resp.json()["collections"]
430+ # links = resp.json()["links"]
431+ # assert len(cols) == 1
432+ # assert cols[0]["id"] == load_test2_collection.id
419433 # assert len(links) == 3
420434 # assert {"root", "self", "previous"} == {link["rel"] for link in links}
421435 # prev_link = list(filter(lambda link: link["rel"] == "previous", links))[0]
422- # assert prev_link["href"].endswith("?offset=0")
436+ # # offset=0 should not be in the previous link (because it's useless)
437+ # assert "offset" not in prev_link["href"]
423438
424439 ###################
425440 # offset=0, should not have next/previous link
@@ -430,6 +445,5 @@ async def test_get_collections_search_limit_offset(
430445 cols = resp .json ()["collections" ]
431446 links = resp .json ()["links" ]
432447 assert len (cols ) == 2
433- # TODO: Check with pgstac
434- # assert len(links) == 2
435- # assert {"root", "self"} == {link["rel"] for link in links}
448+ assert len (links ) == 2
449+ assert {"root" , "self" } == {link ["rel" ] for link in links }
0 commit comments