Skip to content

Commit 1198000

Browse files
committed
removing json merge and patch.
1 parent 0254336 commit 1198000

File tree

3 files changed

+28
-350
lines changed

3 files changed

+28
-350
lines changed

stac_fastapi/api/tests/test_api.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,7 @@ def create_item(self, *args, **kwargs):
427427
def update_item(self, *args, **kwargs):
428428
return "dummy response"
429429

430-
def json_patch_item(self, *args, **kwargs):
431-
return "dummy response"
432-
433-
def merge_patch_item(self, *args, **kwargs):
430+
def patch_item(self, *args, **kwargs):
434431
return "dummy response"
435432

436433
def delete_item(self, *args, **kwargs):
@@ -442,10 +439,7 @@ def create_collection(self, *args, **kwargs):
442439
def update_collection(self, *args, **kwargs):
443440
return "dummy response"
444441

445-
def merge_patch_collection(self, *args, **kwargs):
446-
return "dummy response"
447-
448-
def json_patch_collection(self, *args, **kwargs):
442+
def patch_collection(self, *args, **kwargs):
449443
return "dummy response"
450444

451445
def delete_collection(self, *args, **kwargs):

stac_fastapi/extensions/tests/test_transaction.py

Lines changed: 13 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from typing import Dict, Iterator, List, Union
2+
from typing import Any, Iterator, Union
33

44
import pytest
55
from stac_pydantic import Collection
@@ -11,7 +11,6 @@
1111
from stac_fastapi.extensions.core import TransactionExtension
1212
from stac_fastapi.types.config import ApiSettings
1313
from stac_fastapi.types.core import BaseCoreClient, BaseTransactionsClient
14-
from stac_fastapi.types.stac import PatchOperation
1514

1615

1716
class DummyCoreClient(BaseCoreClient):
@@ -47,30 +46,17 @@ def update_item(self, collection_id: str, item_id: str, item: Item, **kwargs):
4746
"type": item.type,
4847
}
4948

50-
def merge_patch_item(
49+
def patch_item(
5150
self,
5251
collection_id: str,
5352
item_id: str,
54-
item: Dict,
53+
patch: Any,
5554
**kwargs,
5655
):
5756
return {
5857
"path_collection_id": collection_id,
5958
"path_item_id": item_id,
60-
"type": item["type"],
61-
}
62-
63-
def json_patch_item(
64-
self,
65-
collection_id: str,
66-
item_id: str,
67-
operations: List[PatchOperation],
68-
**kwargs,
69-
):
70-
return {
71-
"path_collection_id": collection_id,
72-
"path_item_id": item_id,
73-
"first_op_type": operations[0].op,
59+
"patch": patch,
7460
}
7561

7662
def delete_item(self, item_id: str, collection_id: str, **kwargs):
@@ -85,23 +71,15 @@ def create_collection(self, collection: Collection, **kwargs):
8571
def update_collection(self, collection_id: str, collection: Collection, **kwargs):
8672
return {"path_collection_id": collection_id, "type": collection.type}
8773

88-
def merge_patch_collection(
89-
self,
90-
collection_id: str,
91-
collection: Dict,
92-
**kwargs,
93-
):
94-
return {"path_collection_id": collection_id, "type": collection["type"]}
95-
96-
def json_patch_collection(
74+
def patch_collection(
9775
self,
9876
collection_id: str,
99-
operations: List[PatchOperation],
77+
patch: Any,
10078
**kwargs,
10179
):
10280
return {
10381
"path_collection_id": collection_id,
104-
"first_op_type": operations[0].op,
82+
"patch": patch,
10583
}
10684

10785
def delete_collection(self, collection_id: str, **kwargs):
@@ -134,28 +112,14 @@ def test_update_item(client: TestClient, item: Item) -> None:
134112
assert response.json()["type"] == "Feature"
135113

136114

137-
def test_merge_patch_item(client: TestClient, item: Item) -> None:
115+
def test_patch_item(client: TestClient) -> None:
138116
response = client.patch(
139-
"/collections/a-collection/items/an-item", content=json.dumps(item)
117+
"/collections/a-collection/items/an-item", content="patch request"
140118
)
141119
assert response.is_success, response.text
142120
assert response.json()["path_collection_id"] == "a-collection"
143121
assert response.json()["path_item_id"] == "an-item"
144-
assert response.json()["type"] == "Feature"
145-
146-
147-
def test_json_patch_item(client: TestClient) -> None:
148-
operations = [{"op": "add", "path": "properties.new_prop", "value": "new_prop_value"}]
149-
headers = {"Content-Type": "application/json-patch+json"}
150-
response = client.patch(
151-
"/collections/a-collection/items/an-item",
152-
headers=headers,
153-
content=json.dumps(operations),
154-
)
155-
assert response.is_success, response.text
156-
assert response.json()["path_collection_id"] == "a-collection"
157-
assert response.json()["path_item_id"] == "an-item"
158-
assert response.json()["first_op_type"] == "add"
122+
assert response.json()["patch"] == "patch request"
159123

160124

161125
def test_delete_item(client: TestClient) -> None:
@@ -178,27 +142,14 @@ def test_update_collection(client: TestClient, collection: Collection) -> None:
178142
assert response.json()["type"] == "Collection"
179143

180144

181-
def test_merge_patch_collection(client: TestClient, collection: Collection) -> None:
145+
def test_patch_collection(client: TestClient) -> None:
182146
response = client.patch(
183147
"/collections/a-collection",
184-
content=json.dumps(collection),
185-
)
186-
assert response.is_success, response.text
187-
assert response.json()["path_collection_id"] == "a-collection"
188-
assert response.json()["type"] == "Collection"
189-
190-
191-
def test_json_patch_collection(client: TestClient) -> None:
192-
operations = [{"op": "add", "path": "summaries.new_prop", "value": "new_prop_value"}]
193-
headers = {"Content-Type": "application/json-patch+json"}
194-
response = client.patch(
195-
"/collections/a-collection/items/an-item",
196-
headers=headers,
197-
content=json.dumps(operations),
148+
content="patch request",
198149
)
199150
assert response.is_success, response.text
200151
assert response.json()["path_collection_id"] == "a-collection"
201-
assert response.json()["first_op_type"] == "add"
152+
assert response.json()["patch"] == "patch request"
202153

203154

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

0 commit comments

Comments
 (0)