Skip to content

Commit 45251e4

Browse files
update for stac-fastapi 6.0 (#257)
1 parent 888b84c commit 45251e4

File tree

4 files changed

+30
-92
lines changed

4 files changed

+30
-92
lines changed

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"attrs",
1010
"orjson",
1111
"pydantic",
12-
"stac-fastapi.api>=5.2,<6.0",
13-
"stac-fastapi.extensions>=5.2,<6.0",
14-
"stac-fastapi.types>=5.2,<6.0",
12+
"stac-fastapi.api>=6.0,<7.0",
13+
"stac-fastapi.extensions>=6.0,<7.0",
14+
"stac-fastapi.types>=6.0,<7.0",
1515
"asyncpg",
1616
"buildpg",
1717
"brotli_asgi",

stac_fastapi/pgstac/transactions.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
22

33
import logging
44
import re
5-
from typing import Optional, Union
5+
from typing import List, Optional, Union
66

77
import attr
88
from buildpg import render
99
from fastapi import HTTPException, Request
10+
from stac_fastapi.extensions.core.transaction import AsyncBaseTransactionsClient
11+
from stac_fastapi.extensions.core.transaction.request import (
12+
PartialCollection,
13+
PartialItem,
14+
PatchOperation,
15+
)
1016
from stac_fastapi.extensions.third_party.bulk_transactions import (
1117
AsyncBaseBulkTransactionsClient,
1218
BulkTransactionMethod,
1319
Items,
1420
)
1521
from stac_fastapi.types import stac as stac_types
16-
from stac_fastapi.types.core import AsyncBaseTransactionsClient
1722
from stac_pydantic import Collection, Item, ItemCollection
1823
from starlette.responses import JSONResponse, Response
1924

@@ -203,6 +208,25 @@ async def delete_collection(
203208

204209
return JSONResponse({"deleted collection": collection_id})
205210

211+
async def patch_item(
212+
self,
213+
collection_id: str,
214+
item_id: str,
215+
patch: Union[PartialItem, List[PatchOperation]],
216+
**kwargs,
217+
) -> Optional[Union[stac_types.Item, Response]]:
218+
"""Patch Item."""
219+
raise NotImplementedError
220+
221+
async def patch_collection(
222+
self,
223+
collection_id: str,
224+
patch: Union[PartialCollection, List[PatchOperation]],
225+
**kwargs,
226+
) -> Optional[Union[stac_types.Collection, Response]]:
227+
"""Patch Collection."""
228+
raise NotImplementedError
229+
206230

207231
@attr.s
208232
class BulkTransactionsClient(AsyncBaseBulkTransactionsClient, ClientValidateMixIn):

stac_fastapi/pgstac/types/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class PgstacSearch(BaseSearchPostRequest):
1818
@classmethod
1919
def validate_query_uses_cql(cls, v: str, info: ValidationInfo):
2020
"""Use of Query Extension is not allowed with cql2."""
21-
if info.data.get("query", None) is not None and v != "cql-json":
21+
if info.data.get("query", None) is not None:
2222
raise ValueError(
2323
"Query extension is not available when using pgstac with cql2"
2424
)

tests/resources/test_item.py

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,52 +1356,6 @@ async def test_preserves_extra_link(
13561356
assert extra_link[0]["href"] == expected_href
13571357

13581358

1359-
async def test_item_search_post_filter_extension_cql_explicitlang(
1360-
app_client, load_test_data, load_test_collection
1361-
):
1362-
"""Test POST search with JSONB query (cql json filter extension)"""
1363-
test_item = load_test_data("test_item.json")
1364-
resp = await app_client.post(
1365-
f"/collections/{test_item['collection']}/items", json=test_item
1366-
)
1367-
assert resp.status_code == 201
1368-
1369-
# EPSG is a JSONB key
1370-
params = {
1371-
"collections": [test_item["collection"]],
1372-
"filter-lang": "cql-json",
1373-
"filter": {
1374-
"gt": [
1375-
{"property": "proj:epsg"},
1376-
test_item["properties"]["proj:epsg"] + 1,
1377-
]
1378-
},
1379-
}
1380-
resp = await app_client.post("/search", json=params)
1381-
resp_json = resp.json()
1382-
1383-
assert resp.status_code == 200
1384-
assert len(resp_json.get("features")) == 0
1385-
1386-
params = {
1387-
"collections": [test_item["collection"]],
1388-
"filter-lang": "cql-json",
1389-
"filter": {
1390-
"eq": [
1391-
{"property": "proj:epsg"},
1392-
test_item["properties"]["proj:epsg"],
1393-
]
1394-
},
1395-
}
1396-
resp = await app_client.post("/search", json=params)
1397-
resp_json = resp.json()
1398-
assert len(resp.json()["features"]) == 1
1399-
assert (
1400-
resp_json["features"][0]["properties"]["proj:epsg"]
1401-
== test_item["properties"]["proj:epsg"]
1402-
)
1403-
1404-
14051359
async def test_item_search_post_filter_extension_cql2_2(
14061360
app_client, load_test_data, load_test_collection
14071361
):
@@ -1622,26 +1576,6 @@ async def test_get_filter_extension(app_client, load_test_data, load_test_collec
16221576
assert len(fc["features"]) == 1
16231577
assert fc["features"][0]["id"] == search_id
16241578

1625-
# CQL-JSON
1626-
resp = await app_client.get(
1627-
"/search",
1628-
params={
1629-
"filter-lang": "cql-json",
1630-
"filter": json.dumps(
1631-
{
1632-
"eq": [
1633-
{"property": "id"},
1634-
search_id,
1635-
],
1636-
},
1637-
),
1638-
},
1639-
)
1640-
assert resp.status_code == 200
1641-
fc = resp.json()
1642-
assert len(fc["features"]) == 1
1643-
assert fc["features"][0]["id"] == search_id
1644-
16451579
# CQL2-TEXT
16461580
resp = await app_client.get(
16471581
"/search",
@@ -1669,26 +1603,6 @@ async def test_get_filter_extension(app_client, load_test_data, load_test_collec
16691603
assert len(fc["features"]) == 1
16701604
assert fc["features"][0]["id"] == search_id
16711605

1672-
# CQL-JSON
1673-
resp = await app_client.get(
1674-
f"/collections/{collection_id}/items",
1675-
params={
1676-
"filter-lang": "cql-json",
1677-
"filter": json.dumps(
1678-
{
1679-
"eq": [
1680-
{"property": "id"},
1681-
search_id,
1682-
],
1683-
},
1684-
),
1685-
},
1686-
)
1687-
assert resp.status_code == 200
1688-
fc = resp.json()
1689-
assert len(fc["features"]) == 1
1690-
assert fc["features"][0]["id"] == search_id
1691-
16921606
# CQL2-TEXT
16931607
resp = await app_client.get(
16941608
f"/collections/{collection_id}/items",

0 commit comments

Comments
 (0)