@@ -54,6 +54,9 @@ def patch_item(
5454 patch : Union [PartialItem , List [PatchOperation ]],
5555 ** kwargs ,
5656 ):
57+ if isinstance (patch , PartialItem ):
58+ patch = patch .operations ()
59+
5760 return {
5861 "path_collection_id" : collection_id ,
5962 "path_item_id" : item_id ,
@@ -78,6 +81,9 @@ def patch_collection(
7881 patch : Union [PartialCollection , List [PatchOperation ]],
7982 ** kwargs ,
8083 ):
84+ if isinstance (patch , PartialCollection ):
85+ patch = patch .operations ()
86+
8187 return {
8288 "path_collection_id" : collection_id ,
8389 "patch" : patch ,
@@ -126,15 +132,18 @@ def test_patch_operation_item(client: TestClient) -> None:
126132 ]
127133
128134
129- def test_patch_merge_item (client : TestClient , item : Item ) -> None :
135+ def test_patch_merge_item (client : TestClient ) -> None :
130136 response = client .patch (
131137 "/collections/a-collection/items/an-item" ,
132- content = json .dumps (item ),
138+ content = json .dumps ({ "properties" : { "hello" : "world" , "foo" : None }} ),
133139 )
134140 assert response .is_success , response .text
135141 assert response .json ()["path_collection_id" ] == "a-collection"
136142 assert response .json ()["path_item_id" ] == "an-item"
137- assert response .json ()["patch" ]["type" ] == "Feature"
143+ assert response .json ()["patch" ] == [
144+ {"op" : "add" , "path" : "/properties/hello" , "value" : "world" },
145+ {"op" : "remove" , "path" : "/properties/foo" },
146+ ]
138147
139148
140149def test_delete_item (client : TestClient ) -> None :
@@ -169,14 +178,17 @@ def test_patch_operation_collection(client: TestClient) -> None:
169178 ]
170179
171180
172- def test_patch_merge_collection (client : TestClient , collection : Collection ) -> None :
181+ def test_patch_merge_collection (client : TestClient ) -> None :
173182 response = client .patch (
174183 "/collections/a-collection" ,
175- content = json .dumps (collection ),
184+ content = json .dumps ({ "summaries" : { "hello" : "world" , "foo" : None }} ),
176185 )
177186 assert response .is_success , response .text
178187 assert response .json ()["path_collection_id" ] == "a-collection"
179- assert response .json ()["patch" ]["type" ] == "Collection"
188+ assert response .json ()["patch" ] == [
189+ {"op" : "add" , "path" : "/summaries/hello" , "value" : "world" },
190+ {"op" : "remove" , "path" : "/summaries/foo" },
191+ ]
180192
181193
182194def test_delete_collection (client : TestClient , collection : Collection ) -> None :
0 commit comments