@@ -247,7 +247,7 @@ async def test_merge_patch_item_add(ctx, core_client, txn_client):
247
247
collection_id = collection_id ,
248
248
item_id = item_id ,
249
249
patch = {"properties" : {"foo" : "bar" , "ext:hello" : "world" }},
250
- request = MockRequest ,
250
+ request = MockRequest ( headers = { "content-type" : "application/json" }) ,
251
251
)
252
252
253
253
updated_item = await core_client .get_item (
@@ -266,7 +266,7 @@ async def test_merge_patch_item_remove(ctx, core_client, txn_client):
266
266
collection_id = collection_id ,
267
267
item_id = item_id ,
268
268
patch = {"properties" : {"gsd" : None , "proj:epsg" : None }},
269
- request = MockRequest ,
269
+ request = MockRequest ( headers = { "content-type" : "application/merge-patch+json" }) ,
270
270
)
271
271
272
272
updated_item = await core_client .get_item (
@@ -289,7 +289,17 @@ async def test_json_patch_item_add(ctx, core_client, txn_client):
289
289
{"op" : "add" , "path" : "/properties/ext:hello" , "value" : "world" }
290
290
),
291
291
PatchAddReplaceTest .model_validate (
292
- {"op" : "add" , "path" : "/properties/area/1" , "value" : 10 }
292
+ {
293
+ "op" : "add" ,
294
+ "path" : "/properties/eo:bands/1" ,
295
+ "value" : {
296
+ "gsd" : 10 ,
297
+ "name" : "FB" ,
298
+ "common_name" : "fake_band" ,
299
+ "center_wavelength" : 3.45 ,
300
+ "full_width_half_max" : 1.23 ,
301
+ },
302
+ }
293
303
),
294
304
]
295
305
@@ -306,7 +316,17 @@ async def test_json_patch_item_add(ctx, core_client, txn_client):
306
316
307
317
assert updated_item ["properties" ]["foo" ] == "bar"
308
318
assert updated_item ["properties" ]["ext:hello" ] == "world"
309
- assert updated_item ["properties" ]["area" ] == [2500 , 10 , - 200 ]
319
+ assert (
320
+ len (updated_item ["properties" ]["eo:bands" ])
321
+ == len (ctx .item ["properties" ]["eo:bands" ]) + 1
322
+ )
323
+ assert updated_item ["properties" ]["eo:bands" ][1 ] == {
324
+ "gsd" : 10 ,
325
+ "name" : "FB" ,
326
+ "common_name" : "fake_band" ,
327
+ "center_wavelength" : 3.45 ,
328
+ "full_width_half_max" : 1.23 ,
329
+ }
310
330
311
331
312
332
@pytest .mark .asyncio
@@ -322,7 +342,17 @@ async def test_json_patch_item_replace(ctx, core_client, txn_client):
322
342
{"op" : "replace" , "path" : "/properties/proj:epsg" , "value" : 12345 }
323
343
),
324
344
PatchAddReplaceTest .model_validate (
325
- {"op" : "replace" , "path" : "/properties/area/1" , "value" : 50 }
345
+ {
346
+ "op" : "replace" ,
347
+ "path" : "/properties/eo:bands/1" ,
348
+ "value" : {
349
+ "gsd" : 10 ,
350
+ "name" : "FB" ,
351
+ "common_name" : "fake_band" ,
352
+ "center_wavelength" : 3.45 ,
353
+ "full_width_half_max" : 1.23 ,
354
+ },
355
+ }
326
356
),
327
357
]
328
358
@@ -339,7 +369,16 @@ async def test_json_patch_item_replace(ctx, core_client, txn_client):
339
369
340
370
assert updated_item ["properties" ]["gsd" ] == 100
341
371
assert updated_item ["properties" ]["proj:epsg" ] == 12345
342
- assert updated_item ["properties" ]["area" ] == [2500 , 50 ]
372
+ assert len (updated_item ["properties" ]["eo:bands" ]) == len (
373
+ ctx .item ["properties" ]["eo:bands" ]
374
+ )
375
+ assert updated_item ["properties" ]["eo:bands" ][1 ] == {
376
+ "gsd" : 10 ,
377
+ "name" : "FB" ,
378
+ "common_name" : "fake_band" ,
379
+ "center_wavelength" : 3.45 ,
380
+ "full_width_half_max" : 1.23 ,
381
+ }
343
382
344
383
345
384
@pytest .mark .asyncio
@@ -355,7 +394,11 @@ async def test_json_patch_item_test(ctx, core_client, txn_client):
355
394
{"op" : "test" , "path" : "/properties/proj:epsg" , "value" : 32756 }
356
395
),
357
396
PatchAddReplaceTest .model_validate (
358
- {"op" : "test" , "path" : "/properties/area/1" , "value" : - 200 }
397
+ {
398
+ "op" : "test" ,
399
+ "path" : "/properties/eo:bands/1" ,
400
+ "value" : item ["properties" ]["eo:bands" ][1 ],
401
+ }
359
402
),
360
403
]
361
404
@@ -372,7 +415,9 @@ async def test_json_patch_item_test(ctx, core_client, txn_client):
372
415
373
416
assert updated_item ["properties" ]["gsd" ] == 15
374
417
assert updated_item ["properties" ]["proj:epsg" ] == 32756
375
- assert updated_item ["properties" ]["area" ][1 ] == - 200
418
+ assert (
419
+ updated_item ["properties" ]["eo:bands" ][1 ] == item ["properties" ]["eo:bands" ][1 ]
420
+ )
376
421
377
422
378
423
@pytest .mark .asyncio
@@ -388,7 +433,11 @@ async def test_json_patch_item_move(ctx, core_client, txn_client):
388
433
{"op" : "move" , "path" : "/properties/bar" , "from" : "/properties/proj:epsg" }
389
434
),
390
435
PatchMoveCopy .model_validate (
391
- {"op" : "move" , "path" : "/properties/area/0" , "from" : "/properties/area/1" }
436
+ {
437
+ "op" : "move" ,
438
+ "path" : "/properties/eo:bands/0" ,
439
+ "from" : "/properties/eo:bands/1" ,
440
+ }
392
441
),
393
442
]
394
443
@@ -407,7 +456,17 @@ async def test_json_patch_item_move(ctx, core_client, txn_client):
407
456
assert "gsd" not in updated_item ["properties" ]
408
457
assert updated_item ["properties" ]["bar" ] == 32756
409
458
assert "proj:epsg" not in updated_item ["properties" ]
410
- assert updated_item ["properties" ]["area" ] == [- 200 , 2500 ]
459
+ assert len (updated_item ["properties" ]["eo:bands" ]) == len (
460
+ ctx .item ["properties" ]["eo:bands" ]
461
+ )
462
+ assert (
463
+ updated_item ["properties" ]["eo:bands" ][0 ]
464
+ == ctx .item ["properties" ]["eo:bands" ][1 ]
465
+ )
466
+ assert (
467
+ updated_item ["properties" ]["eo:bands" ][1 ]
468
+ != ctx .item ["properties" ]["eo:bands" ][1 ]
469
+ )
411
470
412
471
413
472
@pytest .mark .asyncio
@@ -423,7 +482,11 @@ async def test_json_patch_item_copy(ctx, core_client, txn_client):
423
482
{"op" : "copy" , "path" : "/properties/bar" , "from" : "/properties/proj:epsg" }
424
483
),
425
484
PatchMoveCopy .model_validate (
426
- {"op" : "copy" , "path" : "/properties/area/0" , "from" : "/properties/area/1" }
485
+ {
486
+ "op" : "copy" ,
487
+ "path" : "/properties/eo:bands/0" ,
488
+ "from" : "/properties/eo:bands/1" ,
489
+ }
427
490
),
428
491
]
429
492
@@ -441,7 +504,12 @@ async def test_json_patch_item_copy(ctx, core_client, txn_client):
441
504
assert updated_item ["properties" ]["foo" ] == updated_item ["properties" ]["gsd" ]
442
505
assert updated_item ["properties" ]["bar" ] == updated_item ["properties" ]["proj:epsg" ]
443
506
assert (
444
- updated_item ["properties" ]["area" ][0 ] == updated_item ["properties" ]["area" ][1 ]
507
+ len (updated_item ["properties" ]["eo:bands" ])
508
+ == len (ctx .item ["properties" ]["eo:bands" ]) + 1
509
+ )
510
+ assert (
511
+ updated_item ["properties" ]["eo:bands" ][0 ]
512
+ == ctx .item ["properties" ]["eo:bands" ][1 ]
445
513
)
446
514
447
515
@@ -453,7 +521,7 @@ async def test_json_patch_item_remove(ctx, core_client, txn_client):
453
521
operations = [
454
522
PatchRemove .model_validate ({"op" : "remove" , "path" : "/properties/gsd" }),
455
523
PatchRemove .model_validate ({"op" : "remove" , "path" : "/properties/proj:epsg" }),
456
- PatchRemove .model_validate ({"op" : "remove" , "path" : "/properties/area /1" }),
524
+ PatchRemove .model_validate ({"op" : "remove" , "path" : "/properties/eo:bands /1" }),
457
525
]
458
526
459
527
await txn_client .patch_item (
@@ -469,7 +537,15 @@ async def test_json_patch_item_remove(ctx, core_client, txn_client):
469
537
470
538
assert "gsd" not in updated_item ["properties" ]
471
539
assert "proj:epsg" not in updated_item ["properties" ]
472
- assert updated_item ["properties" ]["area" ] == [2500 ]
540
+ assert (
541
+ len (updated_item ["properties" ]["eo:bands" ])
542
+ == len (ctx .item ["properties" ]["eo:bands" ]) - 1
543
+ )
544
+ assert (
545
+ updated_item ["properties" ]["eo:bands" ]
546
+ == ctx .item ["properties" ]["eo:bands" ][:1 ]
547
+ + ctx .item ["properties" ]["eo:bands" ][2 :]
548
+ )
473
549
474
550
475
551
@pytest .mark .asyncio
@@ -653,7 +729,7 @@ async def test_merge_patch_collection_add(ctx, core_client, txn_client):
653
729
await txn_client .patch_collection (
654
730
collection_id = collection_id ,
655
731
patch = {"summaries" : {"foo" : "bar" , "hello" : "world" }},
656
- request = MockRequest ,
732
+ request = MockRequest ( headers = { "content-type" : "application/json" }) ,
657
733
)
658
734
659
735
updated_collection = await core_client .get_collection (
@@ -670,7 +746,7 @@ async def test_merge_patch_collection_remove(ctx, core_client, txn_client):
670
746
await txn_client .patch_collection (
671
747
collection_id = collection_id ,
672
748
patch = {"summaries" : {"gsd" : None }},
673
- request = MockRequest ,
749
+ request = MockRequest ( headers = { "content-type" : "application/merge-patch+json" }) ,
674
750
)
675
751
676
752
updated_collection = await core_client .get_collection (
0 commit comments