@@ -186,18 +186,29 @@ def test_experiment_submit_payu_run_error(mock_run, exp):
186186 assert exp .run_id is None
187187
188188
189- TEST_RUN_STDOUT = """137650670.gadi-pbs
190- Loading input manifest: manifests/input.yaml
191- Loading restart manifest: manifests/restart.yaml
192- Loading exe manifest: manifests/exe.yaml
193- payu: Found modules in /opt/Modules/v4.3.0
194- qsub -q express -- /path/to/env/bin/python /path/to/env/bin/payu-run
195- """
189+ @pytest .mark .parametrize (
190+ "example_stdout" ,
191+ [
192+ "137650670.gadi-pbs\n gadi-pbs ID output is first line\n " ,
193+ "gadi-pbs ID\n Is the last line\n 137650670.gadi-pbs\n " ,
194+ ],
195+ )
196+ def test_parse_run_id (example_stdout ):
197+ run_id = parse_run_id (example_stdout )
198+ assert run_id == "137650670.gadi-pbs"
196199
197200
198- def test_parse_run_id ():
199- run_id = parse_run_id (TEST_RUN_STDOUT )
200- assert run_id == "137650670.gadi-pbs"
201+ @pytest .mark .parametrize (
202+ "example_stdout" ,
203+ [
204+ "No job ID here\n Just some output\n " ,
205+ "Multiple IDs\n 12345.gadi-pbs\n 67890.gadi-pbs\n " ,
206+ ],
207+ )
208+ def test_parse_run_id_parsing_error (example_stdout ):
209+ error_msg = "Expected 1 job ID in payu run submission.*"
210+ with pytest .raises (RuntimeError , match = error_msg ):
211+ parse_run_id (example_stdout )
201212
202213
203214@pytest .mark .parametrize (
0 commit comments