@@ -2805,7 +2805,7 @@ def test_generate_canary_files(project):
28052805
28062806 with patch_settings (project , data ) as mock_open , patch_load as mock_load :
28072807 project .load_settings ()
2808- project .generate_canary_files ()
2808+ project .generate_canary_files (local_code_generation = True )
28092809 mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
28102810 mock_load .assert_called_once_with (LANGUAGE )
28112811 canary_root_path = tmp_path / TARGET_CANARY_ROOT_FOLDER
@@ -2858,7 +2858,7 @@ def test_create_template_file(mock_yaml_dump, project):
28582858
28592859 with patch_settings (project , data ) as mock_open , patch_load as mock_load :
28602860 project .load_settings ()
2861- project .generate_canary_files ()
2861+ project .generate_canary_files (local_code_generation = True )
28622862 mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
28632863 mock_load .assert_called_once_with (LANGUAGE )
28642864 expected_template_data = {
@@ -2941,6 +2941,29 @@ def test_generate_canary_files_no_canary_settings(project):
29412941 }
29422942 tmp_path = project .root
29432943 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 )
29442967 project .generate_canary_files ()
29452968
29462969 canary_root_path = tmp_path / TARGET_CANARY_ROOT_FOLDER
@@ -2949,6 +2972,29 @@ def test_generate_canary_files_no_canary_settings(project):
29492972 assert not canary_folder_path .exists ()
29502973
29512974
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+
29522998def test_generate_canary_files_empty_input_files (project ):
29532999 rpdk_config = {
29543000 ARTIFACT_TYPE_RESOURCE : "RESOURCE" ,
@@ -2964,7 +3010,7 @@ def test_generate_canary_files_empty_input_files(project):
29643010 }
29653011 tmp_path = project .root
29663012 setup_rpdk_config (project , rpdk_config )
2967- project .generate_canary_files ()
3013+ project .generate_canary_files (local_code_generation = True )
29683014
29693015 canary_root_path = tmp_path / TARGET_CANARY_ROOT_FOLDER
29703016 canary_folder_path = tmp_path / TARGET_CANARY_FOLDER
@@ -2987,11 +3033,11 @@ def test_generate_canary_files_empty_canary_settings(project):
29873033 }
29883034 tmp_path = project .root
29893035 setup_rpdk_config (project , rpdk_config )
2990- project .generate_canary_files ()
3036+ project .generate_canary_files (local_code_generation = True )
29913037 canary_root_path = tmp_path / TARGET_CANARY_ROOT_FOLDER
29923038 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 ()
29953041
29963042
29973043def _get_mock_yaml_dump_call_arg (
@@ -3045,7 +3091,7 @@ def test_generate_canary_files_with_patch_inputs(mock_yaml_dump, project):
30453091
30463092 with patch_settings (project , data ) as mock_open , patch_load as mock_load :
30473093 project .load_settings ()
3048- project .generate_canary_files ()
3094+ project .generate_canary_files (local_code_generation = True )
30493095 mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
30503096 mock_load .assert_called_once_with (LANGUAGE )
30513097 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):
31253171
31263172 with patch_settings (project , data ) as mock_open , patch_load as mock_load :
31273173 project .load_settings ()
3128- project .generate_canary_files ()
3174+ project .generate_canary_files (local_code_generation = True )
31293175 mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
31303176 mock_load .assert_called_once_with (LANGUAGE )
31313177
@@ -3226,7 +3272,7 @@ def test_create_template_file_by_list_index(mock_yaml_dump, project):
32263272
32273273 with patch_settings (project , data ) as mock_open , patch_load as mock_load :
32283274 project .load_settings ()
3229- project .generate_canary_files ()
3275+ project .generate_canary_files (local_code_generation = True )
32303276 mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
32313277 mock_load .assert_called_once_with (LANGUAGE )
32323278
@@ -3303,7 +3349,7 @@ def test_create_template_file_with_skipped_patch_operation(mock_yaml_dump, proje
33033349
33043350 with patch_settings (project , data ) as mock_open , patch_load as mock_load :
33053351 project .load_settings ()
3306- project .generate_canary_files ()
3352+ project .generate_canary_files (local_code_generation = True )
33073353 mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
33083354 mock_load .assert_called_once_with (LANGUAGE )
33093355
@@ -3381,7 +3427,7 @@ def test_create_template_file_with_patch_inputs_missing_from_create(
33813427
33823428 with patch_settings (project , data ) as mock_open , patch_load as mock_load :
33833429 project .load_settings ()
3384- project .generate_canary_files ()
3430+ project .generate_canary_files (local_code_generation = True )
33853431 mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
33863432 mock_load .assert_called_once_with (LANGUAGE )
33873433
@@ -3477,7 +3523,7 @@ def test_create_template_file_throws_error_with_invalid_path(mock_yaml_dump, pro
34773523 with patch_settings (project , data ) as mock_open , patch_load as mock_load :
34783524 project .load_settings ()
34793525 with pytest .raises (jsonpatch .JsonPointerException ):
3480- project .generate_canary_files ()
3526+ project .generate_canary_files (local_code_generation = True )
34813527 mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
34823528 mock_load .assert_called_once_with (LANGUAGE )
34833529
@@ -3531,7 +3577,7 @@ def test_create_template_file_with_nested_replace_patch_inputs(mock_yaml_dump, p
35313577
35323578 with patch_settings (project , data ) as mock_open , patch_load as mock_load :
35333579 project .load_settings ()
3534- project .generate_canary_files ()
3580+ project .generate_canary_files (local_code_generation = True )
35353581 mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
35363582 mock_load .assert_called_once_with (LANGUAGE )
35373583
@@ -3636,7 +3682,7 @@ def test_create_template_file_with_nested_remove_patch_inputs(mock_yaml_dump, pr
36363682
36373683 with patch_settings (project , data ) as mock_open , patch_load as mock_load :
36383684 project .load_settings ()
3639- project .generate_canary_files ()
3685+ project .generate_canary_files (local_code_generation = True )
36403686 mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
36413687 mock_load .assert_called_once_with (LANGUAGE )
36423688 expected_template_data = {
@@ -3734,7 +3780,7 @@ def test_create_template_file_with_nested_add_patch_inputs(mock_yaml_dump, proje
37343780
37353781 with patch_settings (project , data ) as mock_open , patch_load as mock_load :
37363782 project .load_settings ()
3737- project .generate_canary_files ()
3783+ project .generate_canary_files (local_code_generation = True )
37383784 mock_open .assert_called_once_with ("r" , encoding = "utf-8" )
37393785 mock_load .assert_called_once_with (LANGUAGE )
37403786
0 commit comments