@@ -2805,7 +2805,7 @@ def test_generate_canary_files(project):
2805
2805
2806
2806
with patch_settings (project , data ) as mock_open , patch_load as mock_load :
2807
2807
project .load_settings ()
2808
- project .generate_canary_files ()
2808
+ project .generate_canary_files (local_code_generation = True )
2809
2809
mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
2810
2810
mock_load .assert_called_once_with (LANGUAGE )
2811
2811
canary_root_path = tmp_path / TARGET_CANARY_ROOT_FOLDER
@@ -2858,7 +2858,7 @@ def test_create_template_file(mock_yaml_dump, project):
2858
2858
2859
2859
with patch_settings (project , data ) as mock_open , patch_load as mock_load :
2860
2860
project .load_settings ()
2861
- project .generate_canary_files ()
2861
+ project .generate_canary_files (local_code_generation = True )
2862
2862
mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
2863
2863
mock_load .assert_called_once_with (LANGUAGE )
2864
2864
expected_template_data = {
@@ -2941,6 +2941,29 @@ def test_generate_canary_files_no_canary_settings(project):
2941
2941
}
2942
2942
tmp_path = project .root
2943
2943
setup_rpdk_config (project , rpdk_config )
2944
+ project .generate_canary_files (local_code_generation = True )
2945
+
2946
+ canary_root_path = tmp_path / TARGET_CANARY_ROOT_FOLDER
2947
+ canary_folder_path = tmp_path / TARGET_CANARY_FOLDER
2948
+ assert not canary_root_path .exists ()
2949
+ assert not canary_folder_path .exists ()
2950
+
2951
+
2952
+ def test_generate_canary_files_no_local_code_generation (project ):
2953
+ rpdk_config = {
2954
+ ARTIFACT_TYPE_RESOURCE : "RESOURCE" ,
2955
+ "language" : LANGUAGE ,
2956
+ "runtime" : RUNTIME ,
2957
+ "entrypoint" : None ,
2958
+ "testEntrypoint" : None ,
2959
+ "futureProperty" : "value" ,
2960
+ "typeName" : "AWS::Example::Resource" ,
2961
+ "canarySettings" : {
2962
+ CONTRACT_TEST_FILE_NAMES : ["inputs_1.json" , "inputs_2.json" ],
2963
+ },
2964
+ }
2965
+ tmp_path = project .root
2966
+ setup_rpdk_config (project , rpdk_config )
2944
2967
project .generate_canary_files ()
2945
2968
2946
2969
canary_root_path = tmp_path / TARGET_CANARY_ROOT_FOLDER
@@ -2949,6 +2972,29 @@ def test_generate_canary_files_no_canary_settings(project):
2949
2972
assert not canary_folder_path .exists ()
2950
2973
2951
2974
2975
+ def test_generate_canary_files_false_local_code_generation (project ):
2976
+ rpdk_config = {
2977
+ ARTIFACT_TYPE_RESOURCE : "RESOURCE" ,
2978
+ "language" : LANGUAGE ,
2979
+ "runtime" : RUNTIME ,
2980
+ "entrypoint" : None ,
2981
+ "testEntrypoint" : None ,
2982
+ "futureProperty" : "value" ,
2983
+ "typeName" : "AWS::Example::Resource" ,
2984
+ "canarySettings" : {
2985
+ CONTRACT_TEST_FILE_NAMES : ["inputs_1.json" , "inputs_2.json" ],
2986
+ },
2987
+ }
2988
+ tmp_path = project .root
2989
+ setup_rpdk_config (project , rpdk_config )
2990
+ project .generate_canary_files (local_code_generation = False )
2991
+
2992
+ canary_root_path = tmp_path / TARGET_CANARY_ROOT_FOLDER
2993
+ canary_folder_path = tmp_path / TARGET_CANARY_FOLDER
2994
+ assert not canary_root_path .exists ()
2995
+ assert not canary_folder_path .exists ()
2996
+
2997
+
2952
2998
def test_generate_canary_files_empty_input_files (project ):
2953
2999
rpdk_config = {
2954
3000
ARTIFACT_TYPE_RESOURCE : "RESOURCE" ,
@@ -2964,7 +3010,7 @@ def test_generate_canary_files_empty_input_files(project):
2964
3010
}
2965
3011
tmp_path = project .root
2966
3012
setup_rpdk_config (project , rpdk_config )
2967
- project .generate_canary_files ()
3013
+ project .generate_canary_files (local_code_generation = True )
2968
3014
2969
3015
canary_root_path = tmp_path / TARGET_CANARY_ROOT_FOLDER
2970
3016
canary_folder_path = tmp_path / TARGET_CANARY_FOLDER
@@ -2987,11 +3033,11 @@ def test_generate_canary_files_empty_canary_settings(project):
2987
3033
}
2988
3034
tmp_path = project .root
2989
3035
setup_rpdk_config (project , rpdk_config )
2990
- project .generate_canary_files ()
3036
+ project .generate_canary_files (local_code_generation = True )
2991
3037
canary_root_path = tmp_path / TARGET_CANARY_ROOT_FOLDER
2992
3038
canary_folder_path = tmp_path / TARGET_CANARY_FOLDER
2993
- assert canary_root_path .exists ()
2994
- assert canary_folder_path .exists ()
3039
+ assert not canary_root_path .exists ()
3040
+ assert not canary_folder_path .exists ()
2995
3041
2996
3042
2997
3043
def _get_mock_yaml_dump_call_arg (
@@ -3045,7 +3091,7 @@ def test_generate_canary_files_with_patch_inputs(mock_yaml_dump, project):
3045
3091
3046
3092
with patch_settings (project , data ) as mock_open , patch_load as mock_load :
3047
3093
project .load_settings ()
3048
- project .generate_canary_files ()
3094
+ project .generate_canary_files (local_code_generation = True )
3049
3095
mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
3050
3096
mock_load .assert_called_once_with (LANGUAGE )
3051
3097
canary_root_path = tmp_path / TARGET_CANARY_ROOT_FOLDER
@@ -3125,7 +3171,7 @@ def test_create_template_file_with_patch_inputs(mock_yaml_dump, project):
3125
3171
3126
3172
with patch_settings (project , data ) as mock_open , patch_load as mock_load :
3127
3173
project .load_settings ()
3128
- project .generate_canary_files ()
3174
+ project .generate_canary_files (local_code_generation = True )
3129
3175
mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
3130
3176
mock_load .assert_called_once_with (LANGUAGE )
3131
3177
@@ -3226,7 +3272,7 @@ def test_create_template_file_by_list_index(mock_yaml_dump, project):
3226
3272
3227
3273
with patch_settings (project , data ) as mock_open , patch_load as mock_load :
3228
3274
project .load_settings ()
3229
- project .generate_canary_files ()
3275
+ project .generate_canary_files (local_code_generation = True )
3230
3276
mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
3231
3277
mock_load .assert_called_once_with (LANGUAGE )
3232
3278
@@ -3303,7 +3349,7 @@ def test_create_template_file_with_skipped_patch_operation(mock_yaml_dump, proje
3303
3349
3304
3350
with patch_settings (project , data ) as mock_open , patch_load as mock_load :
3305
3351
project .load_settings ()
3306
- project .generate_canary_files ()
3352
+ project .generate_canary_files (local_code_generation = True )
3307
3353
mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
3308
3354
mock_load .assert_called_once_with (LANGUAGE )
3309
3355
@@ -3381,7 +3427,7 @@ def test_create_template_file_with_patch_inputs_missing_from_create(
3381
3427
3382
3428
with patch_settings (project , data ) as mock_open , patch_load as mock_load :
3383
3429
project .load_settings ()
3384
- project .generate_canary_files ()
3430
+ project .generate_canary_files (local_code_generation = True )
3385
3431
mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
3386
3432
mock_load .assert_called_once_with (LANGUAGE )
3387
3433
@@ -3477,7 +3523,7 @@ def test_create_template_file_throws_error_with_invalid_path(mock_yaml_dump, pro
3477
3523
with patch_settings (project , data ) as mock_open , patch_load as mock_load :
3478
3524
project .load_settings ()
3479
3525
with pytest .raises (jsonpatch .JsonPointerException ):
3480
- project .generate_canary_files ()
3526
+ project .generate_canary_files (local_code_generation = True )
3481
3527
mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
3482
3528
mock_load .assert_called_once_with (LANGUAGE )
3483
3529
@@ -3531,7 +3577,7 @@ def test_create_template_file_with_nested_replace_patch_inputs(mock_yaml_dump, p
3531
3577
3532
3578
with patch_settings (project , data ) as mock_open , patch_load as mock_load :
3533
3579
project .load_settings ()
3534
- project .generate_canary_files ()
3580
+ project .generate_canary_files (local_code_generation = True )
3535
3581
mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
3536
3582
mock_load .assert_called_once_with (LANGUAGE )
3537
3583
@@ -3636,7 +3682,7 @@ def test_create_template_file_with_nested_remove_patch_inputs(mock_yaml_dump, pr
3636
3682
3637
3683
with patch_settings (project , data ) as mock_open , patch_load as mock_load :
3638
3684
project .load_settings ()
3639
- project .generate_canary_files ()
3685
+ project .generate_canary_files (local_code_generation = True )
3640
3686
mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
3641
3687
mock_load .assert_called_once_with (LANGUAGE )
3642
3688
expected_template_data = {
@@ -3734,7 +3780,7 @@ def test_create_template_file_with_nested_add_patch_inputs(mock_yaml_dump, proje
3734
3780
3735
3781
with patch_settings (project , data ) as mock_open , patch_load as mock_load :
3736
3782
project .load_settings ()
3737
- project .generate_canary_files ()
3783
+ project .generate_canary_files (local_code_generation = True )
3738
3784
mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
3739
3785
mock_load .assert_called_once_with (LANGUAGE )
3740
3786
0 commit comments