@@ -514,6 +514,131 @@ def test_execute_merge_cubes(api):
514
514
assert args [1 :] == ('or' ,)
515
515
516
516
517
+ def test_execute_resample_spatial_defaults (api ):
518
+ api .check_result (
519
+ {
520
+ "lc" : {"process_id" : "load_collection" , "arguments" : {"id" : "S2_FOOBAR" }},
521
+ "resample" : {
522
+ "process_id" : "resample_spatial" ,
523
+ "arguments" : {"data" : {"from_node" : "lc" }},
524
+ "result" : True ,
525
+ },
526
+ }
527
+ )
528
+ dummy = dummy_backend .get_collection ("S2_FOOBAR" )
529
+ assert dummy .resample_spatial .call_count == 1
530
+ assert dummy .resample_spatial .call_args .kwargs == {
531
+ "resolution" : 0 ,
532
+ "projection" : None ,
533
+ "method" : "near" ,
534
+ "align" : "upper-left" ,
535
+ }
536
+
537
+
538
+ def test_execute_resample_spatial_custom (api ):
539
+ api .check_result (
540
+ {
541
+ "lc" : {"process_id" : "load_collection" , "arguments" : {"id" : "S2_FOOBAR" }},
542
+ "resample" : {
543
+ "process_id" : "resample_spatial" ,
544
+ "arguments" : {
545
+ "data" : {"from_node" : "lc" },
546
+ "resolution" : [11 , 123 ],
547
+ "projection" : 3857 ,
548
+ "method" : "cubic" ,
549
+ "align" : "lower-right" ,
550
+ },
551
+ "result" : True ,
552
+ },
553
+ }
554
+ )
555
+ dummy = dummy_backend .get_collection ("S2_FOOBAR" )
556
+ assert dummy .resample_spatial .call_count == 1
557
+ assert dummy .resample_spatial .call_args .kwargs == {
558
+ "resolution" : [11 , 123 ],
559
+ "projection" : 3857 ,
560
+ "method" : "cubic" ,
561
+ "align" : "lower-right" ,
562
+ }
563
+
564
+
565
+ @pytest .mark .parametrize (
566
+ "kwargs" ,
567
+ [
568
+ {"resolution" : [1 , 2 , 3 , 4 , 5 ]},
569
+ {"method" : "glossy" },
570
+ {"align" : "justified" },
571
+ ],
572
+ )
573
+ def test_execute_resample_spatial_invalid (api , kwargs ):
574
+ res = api .result (
575
+ {
576
+ "lc" : {"process_id" : "load_collection" , "arguments" : {"id" : "S2_FOOBAR" }},
577
+ "resample" : {
578
+ "process_id" : "resample_spatial" ,
579
+ "arguments" : {"data" : {"from_node" : "lc" }, ** kwargs },
580
+ "result" : True ,
581
+ },
582
+ }
583
+ )
584
+ res .assert_error (status_code = 400 , error_code = "ProcessParameterInvalid" )
585
+
586
+
587
+ def test_execute_resample_cube_spatial_defaults (api ):
588
+ api .check_result (
589
+ {
590
+ "lc1" : {"process_id" : "load_collection" , "arguments" : {"id" : "S2_FOOBAR" }},
591
+ "lc2" : {"process_id" : "load_collection" , "arguments" : {"id" : "SENTINEL1_GRD" }},
592
+ "resample" : {
593
+ "process_id" : "resample_cube_spatial" ,
594
+ "arguments" : {"data" : {"from_node" : "lc1" }, "target" : {"from_node" : "lc2" }},
595
+ "result" : True ,
596
+ },
597
+ }
598
+ )
599
+ cube1 = dummy_backend .get_collection ("S2_FOOBAR" )
600
+ cube2 = dummy_backend .get_collection ("SENTINEL1_GRD" )
601
+ assert cube1 .resample_cube_spatial .call_count == 1
602
+ assert cube1 .resample_cube_spatial .call_args .kwargs == {"target" : cube2 , "method" : "near" }
603
+
604
+
605
+ def test_execute_resample_cube_spatial_custom (api ):
606
+ api .check_result (
607
+ {
608
+ "lc1" : {"process_id" : "load_collection" , "arguments" : {"id" : "S2_FOOBAR" }},
609
+ "lc2" : {"process_id" : "load_collection" , "arguments" : {"id" : "SENTINEL1_GRD" }},
610
+ "resample" : {
611
+ "process_id" : "resample_cube_spatial" ,
612
+ "arguments" : {"data" : {"from_node" : "lc1" }, "target" : {"from_node" : "lc2" }, "method" : "lanczos" },
613
+ "result" : True ,
614
+ },
615
+ }
616
+ )
617
+ cube1 = dummy_backend .get_collection ("S2_FOOBAR" )
618
+ cube2 = dummy_backend .get_collection ("SENTINEL1_GRD" )
619
+ assert cube1 .resample_cube_spatial .call_count == 1
620
+ assert cube1 .resample_cube_spatial .call_args .kwargs == {"target" : cube2 , "method" : "lanczos" }
621
+
622
+
623
+ def test_execute_resample_cube_spatial_invalid (api ):
624
+ res = api .result (
625
+ {
626
+ "lc1" : {"process_id" : "load_collection" , "arguments" : {"id" : "S2_FOOBAR" }},
627
+ "lc2" : {"process_id" : "load_collection" , "arguments" : {"id" : "SENTINEL1_GRD" }},
628
+ "resample" : {
629
+ "process_id" : "resample_cube_spatial" ,
630
+ "arguments" : {"data" : {"from_node" : "lc1" }, "target" : {"from_node" : "lc2" }, "method" : "du chef" },
631
+ "result" : True ,
632
+ },
633
+ }
634
+ )
635
+ res .assert_error (
636
+ status_code = 400 ,
637
+ error_code = "ProcessParameterInvalid" ,
638
+ message = re .compile (r"Invalid enum value 'du chef'\. Expected one of.*cubic.*near" ),
639
+ )
640
+
641
+
517
642
def test_execute_resample_and_merge_cubes (api ):
518
643
api .check_result ("resample_and_merge_cubes.json" )
519
644
dummy = dummy_backend .get_collection ("S2_FAPAR_CLOUDCOVER" )
@@ -522,6 +647,7 @@ def test_execute_resample_and_merge_cubes(api):
522
647
assert last_load_collection_call .target_resolution == [10 , 10 ]
523
648
assert dummy .merge_cubes .call_count == 1
524
649
assert dummy .resample_cube_spatial .call_count == 1
650
+ assert dummy .resample_cube_spatial .call_args .kwargs ["method" ] == "cubic"
525
651
args , kwargs = dummy .merge_cubes .call_args
526
652
assert args [1 :] == ('or' ,)
527
653
0 commit comments