Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- {python: '3.12', pypgstac: '0.9.*'}
- {python: '3.12', pypgstac: '0.8.*'}
- {python: '3.11', pypgstac: '0.8.*'}
- {python: '3.10', pypgstac: '0.8.*'}
- {python: '3.9', pypgstac: '0.8.*'}
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']

timeout-minutes: 20

Expand Down Expand Up @@ -45,7 +40,6 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install .[dev,server,validation]
python -m pip install "pypgstac==${{ matrix.pypgstac }}"

- name: Run test suite
run: python -m pytest --cov stac_fastapi.pgstac --cov-report xml --cov-report term-missing
Expand Down Expand Up @@ -78,7 +72,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
python-version: "3.14"
cache: pip
cache-dependency-path: setup.py

Expand Down Expand Up @@ -107,7 +101,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
python-version: "3.14"
cache: pip
cache-dependency-path: setup.py

Expand Down
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@
"buildpg",
"brotli_asgi",
"cql2>=0.3.6",
"pypgstac>=0.8,<0.10",
"pypgstac>=0.9,<0.10",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be considered as a breaking change but IMO a minor version release should be fine

"hydraters>=0.1.3",
"typing_extensions>=4.9.0",
"jsonpatch>=1.33.0",
"json-merge-patch>=0.3.0",
"hydraters>=0.1.3",
]

extra_reqs = {
"dev": [
"pystac[validation]",
"pypgstac[psycopg]==0.9.*",
"pytest-postgresql",
"pytest",
"pytest-cov",
Expand All @@ -37,6 +36,8 @@
"httpx",
"twine",
"wheel",
"psycopg[binary]==3.1.*",
"psycopg-pool==3.1.*",
],
"docs": [
"black>=23.10.1",
Expand Down Expand Up @@ -68,6 +69,8 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"License :: OSI Approved :: MIT License",
],
keywords="STAC FastAPI COG",
Expand Down
15 changes: 7 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import pytest
from fastapi import APIRouter
from httpx import ASGITransport, AsyncClient
from pypgstac import __version__ as pgstac_version
from pypgstac.db import PgstacDB
from pypgstac.migrate import Migrate
from pytest_postgresql.janitor import DatabaseJanitor
Expand Down Expand Up @@ -54,12 +53,6 @@
logger = logging.getLogger(__name__)


requires_pgstac_0_9_2 = pytest.mark.skipif(
tuple(map(int, pgstac_version.split("."))) < (0, 9, 2),
reason="PgSTAC>=0.9.2 required",
)


@pytest.fixture(scope="session")
def database(postgresql_proc):
with DatabaseJanitor(
Expand All @@ -79,7 +72,13 @@ def database(postgresql_proc):
yield jan


@pytest.fixture(autouse=True)
@pytest.fixture(
params=[
"0.8.6",
"0.9.8",
],
autouse=True,
)
async def pgstac(database):
connection = f"postgresql://{database.user}:{quote(database.password)}@{database.host}:{database.port}/{database.dbname}"
yield
Expand Down
38 changes: 30 additions & 8 deletions tests/resources/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import pytest
from stac_pydantic import Collection

from ..conftest import requires_pgstac_0_9_2


async def test_create_collection(app_client, load_test_data: Callable):
in_json = load_test_data("test_collection.json")
Expand Down Expand Up @@ -349,11 +347,15 @@ async def test_get_collections_search(
assert len(resp.json()["collections"]) == 2


@requires_pgstac_0_9_2
@pytest.mark.asyncio
async def test_collection_search_freetext(
app_client, load_test_collection, load_test2_collection
):
res = await app_client.get("/_mgmt/health")
pgstac_version = res.json()["pgstac"]["pgstac_version"]
if tuple(map(int, pgstac_version.split("."))) < (0, 9, 2):
pass

# free-text
resp = await app_client.get(
"/collections",
Expand Down Expand Up @@ -388,11 +390,15 @@ async def test_collection_search_freetext(
assert len(resp.json()["collections"]) == 0


@requires_pgstac_0_9_2
@pytest.mark.asyncio
async def test_collection_search_freetext_advanced(
app_client_advanced_freetext, load_test_collection, load_test2_collection
):
res = await app_client_advanced_freetext.get("/_mgmt/health")
pgstac_version = res.json()["pgstac"]["pgstac_version"]
if tuple(map(int, pgstac_version.split("."))) < (0, 9, 2):
pass

# free-text
resp = await app_client_advanced_freetext.get(
"/collections",
Expand Down Expand Up @@ -436,9 +442,13 @@ async def test_collection_search_freetext_advanced(
assert len(resp.json()["collections"]) == 0


@requires_pgstac_0_9_2
@pytest.mark.asyncio
async def test_all_collections_with_pagination(app_client, load_test_data):
res = await app_client.get("/_mgmt/health")
pgstac_version = res.json()["pgstac"]["pgstac_version"]
if tuple(map(int, pgstac_version.split("."))) < (0, 9, 2):
pass

data = load_test_data("test_collection.json")
collection_id = data["id"]
for ii in range(0, 12):
Expand Down Expand Up @@ -468,9 +478,13 @@ async def test_all_collections_with_pagination(app_client, load_test_data):
assert {"root", "self"} == {link["rel"] for link in links}


@requires_pgstac_0_9_2
@pytest.mark.asyncio
async def test_all_collections_without_pagination(app_client_no_ext, load_test_data):
res = await app_client_no_ext.get("/_mgmt/health")
pgstac_version = res.json()["pgstac"]["pgstac_version"]
if tuple(map(int, pgstac_version.split("."))) < (0, 9, 2):
pass

data = load_test_data("test_collection.json")
collection_id = data["id"]
for ii in range(0, 12):
Expand All @@ -491,11 +505,15 @@ async def test_all_collections_without_pagination(app_client_no_ext, load_test_d
assert {"root", "self"} == {link["rel"] for link in links}


@requires_pgstac_0_9_2
@pytest.mark.asyncio
async def test_get_collections_search_pagination(
app_client, load_test_collection, load_test2_collection
):
res = await app_client.get("/_mgmt/health")
pgstac_version = res.json()["pgstac"]["pgstac_version"]
if tuple(map(int, pgstac_version.split("."))) < (0, 9, 2):
pass

resp = await app_client.get("/collections")
assert resp.json()["numberReturned"] == 2
assert resp.json()["numberMatched"] == 2
Expand Down Expand Up @@ -621,12 +639,16 @@ async def test_get_collections_search_pagination(
assert {"root", "self"} == {link["rel"] for link in links}


@requires_pgstac_0_9_2
@pytest.mark.xfail(strict=False)
@pytest.mark.asyncio
async def test_get_collections_search_offset_1(
app_client, load_test_collection, load_test2_collection
):
res = await app_client.get("/_mgmt/health")
pgstac_version = res.json()["pgstac"]["pgstac_version"]
if tuple(map(int, pgstac_version.split("."))) < (0, 9, 2):
pass

# BUG: pgstac doesn't return a `prev` link when limit is not set
# offset=1, should have a `previous` link
resp = await app_client.get(
Expand Down
8 changes: 5 additions & 3 deletions tests/resources/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

from stac_fastapi.pgstac.models.links import CollectionLinks

from ..conftest import requires_pgstac_0_9_2


async def test_create_collection(app_client, load_test_data: Callable):
in_json = load_test_data("test_collection.json")
Expand Down Expand Up @@ -1693,9 +1691,13 @@ async def test_get_search_link_media(app_client):
assert get_self_link["type"] == "application/geo+json"


@requires_pgstac_0_9_2
@pytest.mark.asyncio
async def test_item_search_freetext(app_client, load_test_data, load_test_collection):
res = await app_client.get("/_mgmt/health")
pgstac_version = res.json()["pgstac"]["pgstac_version"]
if tuple(map(int, pgstac_version.split("."))) < (0, 9, 2):
pass

test_item = load_test_data("test_item.json")
resp = await app_client.post(
f"/collections/{test_item['collection']}/items", json=test_item
Expand Down
Loading