44import pytest
55from stac_pydantic import Collection
66
7+ from ..conftest import requires_pgstac_0_9_2
8+
79
810async def test_create_collection (app_client , load_test_data : Callable ):
911 in_json = load_test_data ("test_collection.json" )
@@ -305,8 +307,9 @@ async def test_get_collections_search(
305307 assert len (resp .json ()["collections" ]) == 2
306308
307309
310+ @requires_pgstac_0_9_2
308311@pytest .mark .asyncio
309- async def test_get_collections_search_limit_offset (
312+ async def test_get_collections_search_pagination (
310313 app_client , load_test_collection , load_test2_collection
311314):
312315 resp = await app_client .get ("/collections" )
@@ -419,23 +422,6 @@ async def test_get_collections_search_limit_offset(
419422 prev_link = list (filter (lambda link : link ["rel" ] == "previous" , links ))[0 ]
420423 assert "offset" not in prev_link ["href" ]
421424
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
433- # assert len(links) == 3
434- # assert {"root", "self", "previous"} == {link["rel"] for link in links}
435- # prev_link = list(filter(lambda link: link["rel"] == "previous", links))[0]
436- # # offset=0 should not be in the previous link (because it's useless)
437- # assert "offset" not in prev_link["href"]
438-
439425 ###################
440426 # offset=0, should not have next/previous link
441427 resp = await app_client .get (
@@ -447,3 +433,25 @@ async def test_get_collections_search_limit_offset(
447433 assert len (cols ) == 2
448434 assert len (links ) == 2
449435 assert {"root" , "self" } == {link ["rel" ] for link in links }
436+
437+
438+ @pytest .mark .xfail (strict = False )
439+ @pytest .mark .asyncio
440+ async def test_get_collections_search_offset_1 (
441+ app_client , load_test_collection , load_test2_collection
442+ ):
443+ # BUG: pgstac doesn't return a `prev` link when limit is not set
444+ # offset=1, should have a `previous` link
445+ resp = await app_client .get (
446+ "/collections" ,
447+ params = {"offset" : 1 },
448+ )
449+ cols = resp .json ()["collections" ]
450+ links = resp .json ()["links" ]
451+ assert len (cols ) == 1
452+ assert cols [0 ]["id" ] == load_test2_collection .id
453+ assert len (links ) == 3
454+ assert {"root" , "self" , "previous" } == {link ["rel" ] for link in links }
455+ prev_link = list (filter (lambda link : link ["rel" ] == "previous" , links ))[0 ]
456+ # offset=0 should not be in the previous link (because it's useless)
457+ assert "offset" not in prev_link ["href" ]
0 commit comments