11import  json 
2- from  typing  import  Any ,  Iterator , Union 
2+ from  typing  import  Iterator , Union 
33
44import  pytest 
55from  stac_pydantic  import  Collection 
1111from  stac_fastapi .extensions .core  import  TransactionExtension 
1212from  stac_fastapi .types .config  import  ApiSettings 
1313from  stac_fastapi .types .core  import  BaseCoreClient , BaseTransactionsClient 
14+ from  stac_fastapi .types .stac  import  PartialCollection , PartialItem , PatchOperation 
1415
1516
1617class  DummyCoreClient (BaseCoreClient ):
@@ -50,7 +51,7 @@ def patch_item(
5051        self ,
5152        collection_id : str ,
5253        item_id : str ,
53-         patch : Any ,
54+         patch : Union [ PartialItem ,  PatchOperation ] ,
5455        ** kwargs ,
5556    ):
5657        return  {
@@ -74,7 +75,7 @@ def update_collection(self, collection_id: str, collection: Collection, **kwargs
7475    def  patch_collection (
7576        self ,
7677        collection_id : str ,
77-         patch : Any ,
78+         patch : Union [ PartialCollection ,  PatchOperation ] ,
7879        ** kwargs ,
7980    ):
8081        return  {
@@ -114,12 +115,15 @@ def test_update_item(client: TestClient, item: Item) -> None:
114115
115116def  test_patch_item (client : TestClient ) ->  None :
116117    response  =  client .patch (
117-         "/collections/a-collection/items/an-item" , content = '{"patch": true}' 
118+         "/collections/a-collection/items/an-item" ,
119+         content = '[{"op": "add", "path": "/properties/foo", "value": "bar"}]' ,
118120    )
119121    assert  response .is_success , response .text 
120122    assert  response .json ()["path_collection_id" ] ==  "a-collection" 
121123    assert  response .json ()["path_item_id" ] ==  "an-item" 
122-     assert  response .json ()["patch" ] ==  {"patch" : True }
124+     assert  response .json ()["patch" ] ==  [
125+         {"op" : "add" , "path" : "/properties/foo" , "value" : "bar" }
126+     ]
123127
124128
125129def  test_delete_item (client : TestClient ) ->  None :
@@ -145,11 +149,13 @@ def test_update_collection(client: TestClient, collection: Collection) -> None:
145149def  test_patch_collection (client : TestClient ) ->  None :
146150    response  =  client .patch (
147151        "/collections/a-collection" ,
148-         content = '{"patch ": true} ' ,
152+         content = '[{"op ": "add", "path": "/properties/foo", "value": "bar"}] ' ,
149153    )
150154    assert  response .is_success , response .text 
151155    assert  response .json ()["path_collection_id" ] ==  "a-collection" 
152-     assert  response .json ()["patch" ] ==  {"patch" : True }
156+     assert  response .json ()["patch" ] ==  [
157+         {"op" : "add" , "path" : "/properties/foo" , "value" : "bar" }
158+     ]
153159
154160
155161def  test_delete_collection (client : TestClient , collection : Collection ) ->  None :
0 commit comments