Skip to content

Commit 0ddd072

Browse files
committed
Fixing test.
1 parent 3bdfcc7 commit 0ddd072

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

stac_fastapi/extensions/stac_fastapi/extensions/core/transaction.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Transaction extension."""
22

33
from enum import Enum
4-
from typing import List, Literal, Optional, Type, Union
4+
from typing import Any, List, Optional, Type, Union
55

66
import attr
77
from fastapi import APIRouter, Body, FastAPI, Header
@@ -15,7 +15,6 @@
1515
from stac_fastapi.types.config import ApiSettings
1616
from stac_fastapi.types.core import AsyncBaseTransactionsClient, BaseTransactionsClient
1717
from stac_fastapi.types.extension import ApiExtension
18-
from stac_fastapi.types.stac import PartialCollection, PartialItem, PatchOperation
1918

2019

2120
class TransactionConformanceClasses(str, Enum):
@@ -48,17 +47,11 @@ class PatchItem(ItemUri):
4847
"""Patch Item."""
4948

5049
patch: Annotated[
51-
Union[PartialItem, List[PatchOperation]],
50+
Any,
5251
Body(),
5352
] = attr.ib(default=None)
5453
content_type: Annotated[
55-
Optional[
56-
Literal[
57-
"application/json-patch+json",
58-
"application/merge-patch+json",
59-
"application/json",
60-
]
61-
],
54+
Optional[str],
6255
Header(),
6356
] = attr.ib(default="application/json")
6457

@@ -75,17 +68,11 @@ class PatchCollection(CollectionUri):
7568
"""Patch Collection."""
7669

7770
patch: Annotated[
78-
Union[PartialCollection, List[PatchOperation]],
71+
Any,
7972
Body(),
8073
] = attr.ib(default=None)
8174
content_type: Annotated[
82-
Optional[
83-
Literal[
84-
"application/json-patch+json",
85-
"application/merge-patch+json",
86-
"application/json",
87-
]
88-
],
75+
Optional[str],
8976
Header(),
9077
] = attr.ib(default="application/json")
9178

stac_fastapi/extensions/tests/test_transaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_patch_item(client: TestClient) -> None:
119119
assert response.is_success, response.text
120120
assert response.json()["path_collection_id"] == "a-collection"
121121
assert response.json()["path_item_id"] == "an-item"
122-
assert response.json()["patch"] == '{"patch": true}'
122+
assert response.json()["patch"] == {"patch": True}
123123

124124

125125
def test_delete_item(client: TestClient) -> None:
@@ -149,7 +149,7 @@ def test_patch_collection(client: TestClient) -> None:
149149
)
150150
assert response.is_success, response.text
151151
assert response.json()["path_collection_id"] == "a-collection"
152-
assert response.json()["patch"] == '{"patch": true}'
152+
assert response.json()["patch"] == {"patch": True}
153153

154154

155155
def test_delete_collection(client: TestClient, collection: Collection) -> None:

stac_fastapi/types/stac_fastapi/types/core.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""Base clients."""
22

33
import abc
4-
from typing import Annotated, Any, Dict, List, Optional, Union
4+
from typing import Any, Dict, List, Optional, Union
55
from urllib.parse import urljoin
66

77
import attr
8-
from fastapi import Header, Request
8+
from fastapi import Request
99
from geojson_pydantic.geometries import Geometry
1010
from stac_pydantic import Collection, Item, ItemCollection
1111
from stac_pydantic.links import Relations
@@ -86,7 +86,7 @@ def patch_item(
8686
collection_id: str,
8787
item_id: str,
8888
patch: Any,
89-
content_type: Annotated[Optional[str], Header()] = None,
89+
content_type: Optional[str] = None,
9090
**kwargs,
9191
) -> Optional[Union[stac.Item, Response]]:
9292
"""Update an item from a collection.
@@ -161,7 +161,7 @@ def patch_collection(
161161
self,
162162
collection_id: str,
163163
patch: Any,
164-
content_type: Annotated[Optional[str], Header()] = None,
164+
content_type: Optional[str] = None,
165165
**kwargs,
166166
) -> Optional[Union[stac.Collection, Response]]:
167167
"""Update a collection.
@@ -243,7 +243,7 @@ async def patch_item(
243243
collection_id: str,
244244
item_id: str,
245245
patch: Any,
246-
content_type: Annotated[Optional[str], Header()] = None,
246+
content_type: Optional[str] = None,
247247
**kwargs,
248248
) -> Optional[Union[stac.Item, Response]]:
249249
"""Update an item from a collection.
@@ -318,7 +318,7 @@ async def patch_collection(
318318
self,
319319
collection_id: str,
320320
patch: Any,
321-
content_type: Annotated[Optional[str], Header()] = None,
321+
content_type: Optional[str] = None,
322322
**kwargs,
323323
) -> Optional[Union[stac.Collection, Response]]:
324324
"""Update a collection.

0 commit comments

Comments
 (0)