Skip to content

Commit 5108be4

Browse files
committed
add back 0.8 support but allow skip tests
1 parent c95f39a commit 5108be4

File tree

4 files changed

+39
-23
lines changed

4 files changed

+39
-23
lines changed

.github/workflows/cicd.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ jobs:
1313
matrix:
1414
include:
1515
- {python: '3.12', pypgstac: '0.9.*'}
16-
- {python: '3.11', pypgstac: '0.9.*'}
17-
- {python: '3.10', pypgstac: '0.9.*'}
18-
- {python: '3.9', pypgstac: '0.9.*'}
19-
- {python: '3.8', pypgstac: '0.9.*'}
16+
- {python: '3.12', pypgstac: '0.8.*'}
17+
- {python: '3.11', pypgstac: '0.8.*'}
18+
- {python: '3.10', pypgstac: '0.8.*'}
19+
- {python: '3.9', pypgstac: '0.8.*'}
20+
- {python: '3.8', pypgstac: '0.8.*'}
2021

2122
timeout-minutes: 20
2223

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"buildpg",
1818
"brotli_asgi",
1919
"pygeofilter>=0.2",
20-
"pypgstac>=0.9,<0.10",
20+
"pypgstac>=0.8,<0.10",
2121
]
2222

2323
extra_reqs = {

tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from fastapi import APIRouter
1313
from fastapi.responses import ORJSONResponse
1414
from httpx import ASGITransport, AsyncClient
15+
from pypgstac import __version__ as pgstac_version
1516
from pypgstac.db import PgstacDB
1617
from pypgstac.migrate import Migrate
1718
from pytest_postgresql.janitor import DatabaseJanitor
@@ -48,6 +49,12 @@
4849
logger = logging.getLogger(__name__)
4950

5051

52+
requires_pgstac_0_9_2 = pytest.mark.skipif(
53+
tuple(map(int, pgstac_version.split("."))) < (0, 9, 2),
54+
reason="at least PgSTAC>0.9.2 required",
55+
)
56+
57+
5158
@pytest.fixture(scope="session")
5259
def event_loop():
5360
return asyncio.get_event_loop()

tests/resources/test_collection.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import pytest
55
from stac_pydantic import Collection
66

7+
from ..conftest import requires_pgstac_0_9_2
8+
79

810
async 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

Comments
 (0)