def test_parse_output_valid(): """Test `SlurmScheduler.parse_output` for valid arguments.""" number_of_fields = len(SlurmScheduler._detailed_job_info_fields) # pylint: disable=protected-access detailed_job_info = {'stdout': f"Header\n{'|' * number_of_fields}"} scheduler = SlurmScheduler() assert scheduler.parse_output(detailed_job_info, '', '') is None
def test_parse_out_of_memory(): """Test that for job that failed due to OOM `parse_output` return the `ERROR_SCHEDULER_OUT_OF_MEMORY` code.""" from aiida.engine import CalcJob scheduler = SlurmScheduler() stdout = '' stderr = '' detailed_job_info = { 'retval': 0, 'stderr': '', 'stdout': """|||||||||||||||||||||||||||||||||||||||||||||||||| |||||||||||||||||||||||||||||||||||||||||OUT_OF_MEMORY|||||||||""" } # yapf: disable exit_code = scheduler.parse_output(detailed_job_info, stdout, stderr) assert exit_code == CalcJob.exit_codes.ERROR_SCHEDULER_OUT_OF_MEMORY # pylint: disable=no-member
def test_parse_output_invalid(detailed_job_info, expected): """Test `SlurmScheduler.parse_output` for various invalid arguments.""" scheduler = SlurmScheduler() with pytest.raises(expected): scheduler.parse_output(detailed_job_info, '', '')