77
88from stac_fastapi .extensions .third_party .bulk_transactions import Items
99from stac_fastapi .types .errors import ConflictError , NotFoundError
10- from stac_fastapi .types .stac import PatchOperation
10+ from stac_fastapi .types .stac import PatchAddReplaceTest , PatchMoveCopy , PatchRemove
1111
1212from ..conftest import MockRequest , create_item
1313
@@ -282,7 +282,9 @@ async def test_json_patch_item_add(ctx, core_client, txn_client):
282282 collection_id = item ["collection" ]
283283 item_id = item ["id" ]
284284 operations = [
285- PatchOperation (** {"op" : "add" , "path" : "properties.foo" , "value" : "bar" }),
285+ PatchAddReplaceTest .model_validate (
286+ {"op" : "add" , "path" : "properties.foo" , "value" : "bar" }
287+ ),
286288 ]
287289
288290 await txn_client .json_patch_item (
@@ -305,7 +307,9 @@ async def test_json_patch_item_replace(ctx, core_client, txn_client):
305307 collection_id = item ["collection" ]
306308 item_id = item ["id" ]
307309 operations = [
308- PatchOperation (** {"op" : "replace" , "path" : "properties.foo" , "value" : 100 }),
310+ PatchAddReplaceTest .model_validate (
311+ {"op" : "replace" , "path" : "properties.foo" , "value" : 100 }
312+ ),
309313 ]
310314
311315 await txn_client .json_patch_item (
@@ -328,7 +332,9 @@ async def test_json_patch_item_test(ctx, core_client, txn_client):
328332 collection_id = item ["collection" ]
329333 item_id = item ["id" ]
330334 operations = [
331- PatchOperation (** {"op" : "test" , "path" : "properties.foo" , "value" : 100 }),
335+ PatchAddReplaceTest .model_validate (
336+ {"op" : "test" , "path" : "properties.foo" , "value" : 100 }
337+ ),
332338 ]
333339
334340 await txn_client .json_patch_item (
@@ -351,8 +357,8 @@ async def test_json_patch_item_move(ctx, core_client, txn_client):
351357 collection_id = item ["collection" ]
352358 item_id = item ["id" ]
353359 operations = [
354- PatchOperation (
355- ** {"op" : "move" , "path" : "properties.bar" , "from" : "properties.foo" }
360+ PatchMoveCopy . model_validate (
361+ {"op" : "move" , "path" : "properties.bar" , "from" : "properties.foo" }
356362 ),
357363 ]
358364
@@ -377,8 +383,8 @@ async def test_json_patch_item_copy(ctx, core_client, txn_client):
377383 collection_id = item ["collection" ]
378384 item_id = item ["id" ]
379385 operations = [
380- PatchOperation (
381- ** {"op" : "copy" , "path" : "properties.foo" , "from" : "properties.bar" }
386+ PatchMoveCopy . model_validate (
387+ {"op" : "copy" , "path" : "properties.foo" , "from" : "properties.bar" }
382388 ),
383389 ]
384390
@@ -402,8 +408,8 @@ async def test_json_patch_item_remove(ctx, core_client, txn_client):
402408 collection_id = item ["collection" ]
403409 item_id = item ["id" ]
404410 operations = [
405- PatchOperation ( ** {"op" : "remove" , "path" : "properties.foo" }),
406- PatchOperation ( ** {"op" : "remove" , "path" : "properties.bar" }),
411+ PatchRemove . model_validate ( {"op" : "remove" , "path" : "properties.foo" }),
412+ PatchRemove . model_validate ( {"op" : "remove" , "path" : "properties.bar" }),
407413 ]
408414
409415 await txn_client .json_patch_item (
@@ -427,8 +433,8 @@ async def test_json_patch_item_test_wrong_value(ctx, core_client, txn_client):
427433 collection_id = item ["collection" ]
428434 item_id = item ["id" ]
429435 operations = [
430- PatchOperation (
431- ** {"op" : "test" , "path" : "properties.platform" , "value" : "landsat-9" }
436+ PatchAddReplaceTest . model_validate (
437+ {"op" : "test" , "path" : "properties.platform" , "value" : "landsat-9" }
432438 ),
433439 ]
434440
@@ -450,8 +456,8 @@ async def test_json_patch_item_replace_property_does_not_exists(
450456 collection_id = item ["collection" ]
451457 item_id = item ["id" ]
452458 operations = [
453- PatchOperation (
454- ** {"op" : "replace" , "path" : "properties.foo" , "value" : "landsat-9" }
459+ PatchAddReplaceTest . model_validate (
460+ {"op" : "replace" , "path" : "properties.foo" , "value" : "landsat-9" }
455461 ),
456462 ]
457463
@@ -473,7 +479,7 @@ async def test_json_patch_item_remove_property_does_not_exists(
473479 collection_id = item ["collection" ]
474480 item_id = item ["id" ]
475481 operations = [
476- PatchOperation ( ** {"op" : "remove" , "path" : "properties.foo" }),
482+ PatchRemove . model_validate ( {"op" : "remove" , "path" : "properties.foo" }),
477483 ]
478484
479485 with pytest .raises (ConflictError ):
@@ -494,8 +500,8 @@ async def test_json_patch_item_move_property_does_not_exists(
494500 collection_id = item ["collection" ]
495501 item_id = item ["id" ]
496502 operations = [
497- PatchOperation (
498- ** {"op" : "move" , "path" : "properties.bar" , "from" : "properties.foo" }
503+ PatchMoveCopy . model_validate (
504+ {"op" : "move" , "path" : "properties.bar" , "from" : "properties.foo" }
499505 ),
500506 ]
501507
@@ -517,8 +523,8 @@ async def test_json_patch_item_copy_property_does_not_exists(
517523 collection_id = item ["collection" ]
518524 item_id = item ["id" ]
519525 operations = [
520- PatchOperation (
521- ** {"op" : "copy" , "path" : "properties.bar" , "from" : "properties.foo" }
526+ PatchMoveCopy . model_validate (
527+ {"op" : "copy" , "path" : "properties.bar" , "from" : "properties.foo" }
522528 ),
523529 ]
524530
0 commit comments