11import json
2- from typing import Iterator , Union
2+ from typing import Iterator , List , Union
33
44import pytest
55from stac_pydantic import Collection
@@ -51,7 +51,7 @@ def patch_item(
5151 self ,
5252 collection_id : str ,
5353 item_id : str ,
54- patch : Union [PartialItem , PatchOperation ],
54+ patch : Union [PartialItem , List [ PatchOperation ] ],
5555 ** kwargs ,
5656 ):
5757 return {
@@ -75,7 +75,7 @@ def update_collection(self, collection_id: str, collection: Collection, **kwargs
7575 def patch_collection (
7676 self ,
7777 collection_id : str ,
78- patch : Union [PartialCollection , PatchOperation ],
78+ patch : Union [PartialCollection , List [ PatchOperation ] ],
7979 ** kwargs ,
8080 ):
8181 return {
@@ -113,7 +113,7 @@ def test_update_item(client: TestClient, item: Item) -> None:
113113 assert response .json ()["type" ] == "Feature"
114114
115115
116- def test_patch_item (client : TestClient ) -> None :
116+ def test_patch_operation_item (client : TestClient ) -> None :
117117 response = client .patch (
118118 "/collections/a-collection/items/an-item" ,
119119 content = '[{"op": "add", "path": "/properties/foo", "value": "bar"}]' ,
@@ -126,6 +126,17 @@ def test_patch_item(client: TestClient) -> None:
126126 ]
127127
128128
129+ def test_patch_merge_item (client : TestClient , item : Item ) -> None :
130+ response = client .patch (
131+ "/collections/a-collection/items/an-item" ,
132+ content = json .dumps (item ),
133+ )
134+ assert response .is_success , response .text
135+ assert response .json ()["path_collection_id" ] == "a-collection"
136+ assert response .json ()["path_item_id" ] == "an-item"
137+ assert response .json ()["patch" ]["type" ] == "Feature"
138+
139+
129140def test_delete_item (client : TestClient ) -> None :
130141 response = client .delete ("/collections/a-collection/items/an-item" )
131142 assert response .is_success , response .text
@@ -146,7 +157,7 @@ def test_update_collection(client: TestClient, collection: Collection) -> None:
146157 assert response .json ()["type" ] == "Collection"
147158
148159
149- def test_patch_collection (client : TestClient ) -> None :
160+ def test_patch_operation_collection (client : TestClient ) -> None :
150161 response = client .patch (
151162 "/collections/a-collection" ,
152163 content = '[{"op": "add", "path": "/properties/foo", "value": "bar"}]' ,
@@ -158,6 +169,16 @@ def test_patch_collection(client: TestClient) -> None:
158169 ]
159170
160171
172+ def test_patch_merge_collection (client : TestClient , collection : Collection ) -> None :
173+ response = client .patch (
174+ "/collections/a-collection" ,
175+ content = json .dumps (collection ),
176+ )
177+ assert response .is_success , response .text
178+ assert response .json ()["path_collection_id" ] == "a-collection"
179+ assert response .json ()["patch" ]["type" ] == "Collection"
180+
181+
161182def test_delete_collection (client : TestClient , collection : Collection ) -> None :
162183 response = client .delete ("/collections/a-collection" )
163184 assert response .is_success , response .text
0 commit comments