2525 _determine_bazel_rule ,
2626 _build_bazel_target ,
2727 _locate_and_extract_artifact ,
28+ _run_post_processor ,
2829 handle_generate ,
2930 handle_build ,
3031 handle_configure ,
@@ -165,6 +166,37 @@ def test_locate_and_extract_artifact_fails(mocker, caplog):
165166 )
166167
167168
169+ def test_run_post_processor_success (mocker , caplog ):
170+ """
171+ Tests that the post-processor helper calls the correct command.
172+ """
173+ caplog .set_level (logging .INFO )
174+ mocker .patch ("cli.synthtool" , create = True )
175+ mock_chdir = mocker .patch ("cli.os.chdir" )
176+ mock_subprocess = mocker .patch ("cli.subprocess.run" )
177+
178+ _run_post_processor ()
179+
180+ mock_subprocess .assert_called_once ()
181+
182+ assert mock_subprocess .call_args .kwargs ["cwd" ] == "output"
183+ assert "Python post-processor ran successfully." in caplog .text
184+
185+
186+ def test_locate_and_extract_artifact_fails (mocker , caplog ):
187+ """
188+ Tests that an exception is raised if the subprocess command fails.
189+ """
190+ caplog .set_level (logging .INFO )
191+ mocker .patch (
192+ "cli.subprocess.run" ,
193+ side_effect = subprocess .CalledProcessError (1 , "cmd" , stderr = "Python error" ),
194+ )
195+
196+ with pytest .raises (ValueError ):
197+ _run_post_processor ()
198+
199+
168200def test_handle_generate_success (caplog , mock_generate_request_file , mocker ):
169201 """
170202 Tests the successful execution path of handle_generate.
@@ -175,8 +207,8 @@ def test_handle_generate_success(caplog, mock_generate_request_file, mocker):
175207 "cli._determine_bazel_rule" , return_value = "mock-rule"
176208 )
177209 mock_build_target = mocker .patch ("cli._build_bazel_target" )
178-
179210 mock_locate_and_extract_artifact = mocker .patch ("cli._locate_and_extract_artifact" )
211+ mock_run_post_processor = mocker .patch ("cli._run_post_processor" )
180212
181213 handle_generate ()
182214
0 commit comments